From 0dcdd79a41c9593f992652c5d64b462c1cc1342f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krystian=20Bac=C5=82awski?= Date: Sun, 5 Jan 2014 13:04:09 +0100 Subject: [PATCH] Add MUI example. Modify install-sdk to create static library. --- examples/.gitignore | 1 + examples/Makefile | 9 +++++-- examples/hello-mui.c | 64 ++++++++++++++++++++++++++++++++++++++++++++ install-sdk.sh | 40 +++++++++++++++++++++++++-- sdk/mui.sdk | 1 + 5 files changed, 111 insertions(+), 4 deletions(-) create mode 100644 examples/hello-mui.c diff --git a/examples/.gitignore b/examples/.gitignore index ce01362..1dfaf09 100644 --- a/examples/.gitignore +++ b/examples/.gitignore @@ -1 +1,2 @@ hello +hello-mui diff --git a/examples/Makefile b/examples/Makefile index 829628e..a602cd2 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -1,13 +1,18 @@ CC = m68k-amigaos-gcc -noixemul -s CFLAGS = -Os -Wall -fomit-frame-pointer -all: hello +all: hello hello-mui hello: LDLIBS = -lnix13 hello: CC += -fbaserel hello: CFLAGS += -m68000 -msmall-code hello: hello.c +hello-mui: CC += -fbaserel +hello-mui: CFLAGS += -m68020 -msmall-code +hello-mui: LDLIBS = -lmui +hello-mui: hello-mui.c + clean: - rm -f hello + rm -f hello hello-mui rm -f *.o *~ diff --git a/examples/hello-mui.c b/examples/hello-mui.c new file mode 100644 index 0000000..9d3b17a --- /dev/null +++ b/examples/hello-mui.c @@ -0,0 +1,64 @@ +/* Taken from: http://aros.sourceforge.net/documentation/developers/zune-application-development.php */ + +#include +#include + +#include +#include +#include +#include + +/* Otherwise auto open will try version 37, and muimaster.library has version + * 19.x for MUI 3.8 */ +int __oslibversion = 0; + +/* We don't use command line arguments. */ +int __nocommandline = 1; + +int main(void) { + Object *wnd, *app, *but; + + // GUI creation + app = ApplicationObject, + SubWindow, wnd = WindowObject, + MUIA_Window_Title, "Hello world!", + WindowContents, VGroup, + Child, TextObject, + MUIA_Text_Contents, "\33cHello world!\nHow are you?", + End, + Child, but = SimpleButton("_Ok"), + End, + End, + End; + + if (app != NULL) { + ULONG sigs = 0; + + // Click Close gadget or hit Escape to quit + DoMethod(wnd, MUIM_Notify, MUIA_Window_CloseRequest, TRUE, + (APTR)app, 2, + MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit); + + // Click the button to quit + DoMethod(but, MUIM_Notify, MUIA_Pressed, FALSE, + (APTR)app, 2, + MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit); + + // Open the window + set(wnd, MUIA_Window_Open, TRUE); + + while((LONG)DoMethod(app, MUIM_Application_NewInput, (APTR)&sigs) + != MUIV_Application_ReturnID_Quit) { + if (sigs) { + sigs = Wait(sigs | SIGBREAKF_CTRL_C); + if (sigs & SIGBREAKF_CTRL_C) + break; + } + } + + // Destroy our application and all its objects + MUI_DisposeObject(app); + } + + return 0; +} diff --git a/install-sdk.sh b/install-sdk.sh index 0228338..ab3f144 100755 --- a/install-sdk.sh +++ b/install-sdk.sh @@ -33,6 +33,17 @@ function add_stubs { rm -f "${obj}" } +function add_lib { + local src="$1" + local lib="$2" + local obj="${src%.a}.o" + + echo "${src} -> ${PREFIX}/lib/${lib}" + m68k-amigaos-gcc "${CFLAGS}" -noixemul -c -o "${obj}" "${src}" && \ + m68k-amigaos-ar rcs "${PREFIX}/lib/${lib}" "${obj}" + rm -f "${obj}" +} + function install_sdk { local name="$1" local sdk="$2" @@ -88,8 +99,8 @@ function install_sdk { ;; "stubs") path=${line[2]} - name=$(basename ${path}) - file="${name%_lib.sfd}.c" + filepart=$(basename ${path}) + file="${filepart%_lib.sfd}.c" echo "${path} -> ${file}" sfdc --quiet --target=m68k-amigaos --mode=autoopen \ @@ -110,6 +121,31 @@ function install_sdk { CFLAGS="-Wall -O3 -fomit-frame-pointer -fbaserel32 -DSMALL_DATA -m68020" add_stubs "${file}" "libb32/libm020/libnix" ;; + "lib") + path=${line[2]} + filepart=$(basename ${path}) + file="${filepart%_lib.sfd}.c" + lib="lib${name}.a" + + echo "${path} -> ${file}" + sfdc --quiet --target=m68k-amigaos --mode=stubs \ + --output="${file}" ${path} + + CFLAGS="-Wall -O3 -fomit-frame-pointer" + add_lib "${file}" "${lib}" + CFLAGS="-Wall -O3 -fomit-frame-pointer -fbaserel -DSMALL_DATA" + add_lib "${file}" "libb/${lib}" + CFLAGS="-Wall -O3 -fomit-frame-pointer -m68020" + add_lib "${file}" "libm020/${lib}" + CFLAGS="-Wall -O3 -fomit-frame-pointer -fbaserel -DSMALL_DATA -m68020" + add_lib "${file}" "libb/libm020/${lib}" + CFLAGS="-Wall -O3 -fomit-frame-pointer -m68020 -m68881" + add_lib "${file}" "libm020/libm881/${lib}" + CFLAGS="-Wall -O3 -fomit-frame-pointer -fbaserel -DSMALL_DATA -m68020 -m68881" + add_lib "${file}" "libb/libm020/libm881/${lib}" + CFLAGS="-Wall -O3 -fomit-frame-pointer -fbaserel32 -DSMALL_DATA -m68020" + add_lib "${file}" "libb32/libm020/${lib}" + ;; *) echo "Unknown preprocessor: '${line}'" exit 1 diff --git a/sdk/mui.sdk b/sdk/mui.sdk index b779f28..4eb227a 100644 --- a/sdk/mui.sdk +++ b/sdk/mui.sdk @@ -77,3 +77,4 @@ MUI/Developer/FD/muimaster_lib.fd fd2sfd : MUI/Developer/FD/muimaster_lib.fd MUI/Developer/C/Include/clib/muimaster_protos.h sfdc : muimaster_lib.sfd stubs : muimaster_lib.sfd +lib : muimaster_lib.sfd