# HG changeset patch # User Olaf Wintermann # Date 1736005128 -3600 # Node ID bb7da585debc43eccbb04f78dff116845dd0ae05 # Parent fe49cff3c571dd9fe45bfc87b985959f3219490f# Parent ea949c0109d8a22364aba98d2a98291acc4f5010 merge diff -r fe49cff3c571 -r bb7da585debc .hgignore --- a/.hgignore Sun May 23 09:44:43 2021 +0200 +++ b/.hgignore Sat Jan 04 16:38:48 2025 +0100 @@ -1,10 +1,8 @@ relre:^build/.*$ relre:^config.mk$ relre:^core$ -relre:^ui/wpf/UIcore/obj -relre:^ui/wpf/UIwrapper/.vs -relre:^ui/wpf/UIwrapper/UIwrapper.VC -relre:^ui/wpf/UIwrapper/UIwrapper/Debug -relre:^ui/wpf/UIwrapper/UIwrapper/Release -relre:^ui/wpf/UIwrapper/UIwrapper/x64 -relre:^ui/wpf/UIwrapper/ipch \ No newline at end of file +relre:^make/vs/.vs/.* +relre:^make/vs/packages/.* +relre:^make/vs/.*vcxproj\.user +relre:^make/xcode/toolkit/toolkit.xcodeproj/xcuserdata/.* +relre:^make/xcode/toolkit/toolkit.xcodeproj/project.xcworkspace/xcuserdata/.* \ No newline at end of file diff -r fe49cff3c571 -r bb7da585debc application/Makefile --- a/application/Makefile Sun May 23 09:44:43 2021 +0200 +++ b/application/Makefile Sat Jan 04 16:38:48 2025 +0100 @@ -26,20 +26,20 @@ # POSSIBILITY OF SUCH DAMAGE. # -BUILD_ROOT = ../ +BUILD_ROOT = .. include ../config.mk CFLAGS += -I../ui/ -I../ucx SRC = main.c -OBJ = $(SRC:%.c=../build/application/%.$(OBJ_EXT)) +OBJ = $(SRC:%.c=../build/application/%$(OBJ_EXT)) all: ../build/bin/mk12 ../build/bin/mk12: $(OBJ) $(BUILD_ROOT)/build/lib/libuitk.a - $(LD) -o ../build/bin/mk12$(APP_EXT) $(OBJ) -L$(BUILD_ROOT)/build/lib -luitk -lucx $(LDFLAGS) $(TK_LDFLAGS) + $(CC) -o ../build/bin/mk12$(APP_EXT) $(OBJ) -L$(BUILD_ROOT)/build/lib -luitk -lucx $(LDFLAGS) $(TK_LDFLAGS) -../build/application/%.$(OBJ_EXT): %.c +../build/application/%$(OBJ_EXT): %.c $(CC) $(CFLAGS) $(TK_CFLAGS) -o $@ -c $< diff -r fe49cff3c571 -r bb7da585debc application/main.c --- a/application/main.c Sun May 23 09:44:43 2021 +0200 +++ b/application/main.c Sat Jan 04 16:38:48 2025 +0100 @@ -28,62 +28,433 @@ #include #include +#include #include -#include -#include +#include +#include + +#if !defined(UI_COCOA) && !defined(UI_MOTIF) typedef struct { + UiString *str1; + UiString *str2; + UiString *path; UiText *text; + UiDouble *progress; + UiList *list; + UiList *list2; + UiList *menulist; + UiInteger *radio; + UiInteger *tabview; + UiGeneric *image; + UiList *srclist1; + UiList *srclist2; + UiList *items; } MyDocument; MyDocument *doc1; MyDocument *doc2; +UIWIDGET tabview; + +static UiCondVar *cond; +static int thr_end = 0; +static int thr_started = 0; + +int threadfunc(void *data) { + printf("thr wait for data...\n"); + ui_condvar_wait(cond); + printf("thr data received: {%s} [%d]\n", cond->data, cond->intdata); + ui_condvar_destroy(cond); + cond = NULL; + + return 0; +} + +void action_start_thread(UiEvent *event, void *data) { + if(!thr_started) { + cond = ui_condvar_create(); + ui_job(event->obj, threadfunc, NULL, NULL, NULL); + thr_started = 1; + } +} + +void action_notify_thread(UiEvent *event, void *data) { + if(!thr_end) { + ui_condvar_signal(cond, "hello thread", 123); + thr_end = 1; + } +} void action_menu(UiEvent *event, void *userdata) { - printf("action_menu: %s\n", (char*)userdata); + +} + +void action_file_selected(UiEvent *event, void *userdata) { + UiFileList *files = event->eventdata; + MyDocument *doc = event->document; + printf("files: %d\n", (int)files->nfiles); + if(files->nfiles > 0) { + printf("selected file: %s\n", files->files[0]); + ui_image_load_file(doc->image, files->files[0]); + } } void action_button(UiEvent *event, void *userdata) { - printf("button test\n"); - MyDocument *doc = event->document; - if(!doc) { - printf("no document\n"); - return; - } - - char *text = doc->text->get(doc->text); - printf("text: {\n%s\n}\n", text); + ui_openfiledialog(event->obj, UI_FILEDIALOG_SELECT_SINGLE, action_file_selected, NULL); } void action_switch(UiEvent *event, void *userdata) { - if(event->document == doc1) { - ui_set_document(event->obj, doc2); - } else { - ui_set_document(event->obj, doc1); - } + +} + +void action_toolbar_button(UiEvent *event, void *userdata) { + printf("toolbar button\n"); + + ui_dialog(event->obj, .title = "Dialog Title", .content = "Content Label", .button1_label = "btn1", .button2_label = "btn2", .input = TRUE, .closebutton_label = "Cancel"); +} + +void action_dialog_button(UiEvent *event, void *userdata) { + ui_close(event->obj); +} + +void action_dialog_onactivate(UiEvent *event, void *userdata) { + printf("textfield activate\n"); + ui_close(event->obj); } +void action_toolbar_dialog(UiEvent *event, void *userdata) { + + UiObject *dialog = ui_dialog_window(event->obj, .title = "Dialog Window", .lbutton1 = "Cancel 1", .lbutton2 = "Btn2", .rbutton3 = "Btn3", .rbutton4 = "Login 4", .onclick = action_dialog_button, .default_button = 4, .show_closebutton = UI_OFF); + + ui_vbox(dialog, .margin = 10, .spacing = 10) { + ui_label(dialog, .label = "Enter password:"); + ui_passwordfield(dialog, .varname = "password", .onactivate = action_dialog_onactivate); + } + + ui_show(dialog); +} + +void action_toolbar_newwindow(UiEvent *event, void *userdata) { + UiObject *obj = ui_simple_window("New Window", NULL); + + ui_headerbar0(obj) { + ui_headerbar_start(obj) { + ui_button(obj, .label = "Open"); + } + ui_headerbar_end(obj) { + ui_button(obj, .label = "Test"); + } + } + + ui_textarea(obj, .varname="text"); + + ui_show(obj); +} MyDocument* create_doc(void) { MyDocument *doc = ui_document_new(sizeof(MyDocument)); UiContext *docctx = ui_document_context(doc); - doc->text = ui_text_new(docctx, "text"); + doc->str1 = ui_string_new(docctx, "str1"); + doc->str1 = ui_string_new(docctx, "str2"); + doc->path = ui_string_new(docctx, "path"); + doc->progress = ui_double_new(docctx, "progress"); + doc->list = ui_list_new(docctx, "list"); + ui_list_append(doc->list, "test1"); + ui_list_append(doc->list, "test2"); + ui_list_append(doc->list, "test3"); + doc->list2 = ui_list_new(docctx, "list2"); + ui_list_append(doc->list2, "test1"); + ui_list_append(doc->list2, "test2"); + ui_list_append(doc->list2, "test3"); + doc->radio = ui_int_new(docctx, "radio"); + doc->tabview = ui_int_new(docctx, "tabview"); + doc->image = ui_generic_new(docctx, "image"); + + doc->srclist1 = ui_list_new(docctx, "srclist1"); + doc->srclist2 = ui_list_new(docctx, "srclist2"); + ui_list_append(doc->srclist1, "test1"); + ui_list_append(doc->srclist1, "test2"); + ui_list_append(doc->srclist1, "test3"); + ui_list_append(doc->srclist2, "x1"); + ui_list_append(doc->srclist2, "x2"); + + doc->items = ui_list_new(docctx, "items"); + ui_list_append(doc->items, "Item 1"); + ui_list_append(doc->items, "Item 2"); + ui_list_append(doc->items, "Item 3"); + + //doc->text = ui_text_new(docctx, "text"); return doc; } +UiIcon *icon = NULL; + +static void* list_getvalue(void *elm, int col) { + /* + if(col == 0) { + if(!icon) { + icon = ui_icon("folder", 24); + } + return icon; + } + */ + + char *str = elm; + return col == 0 ? str : "x"; +} + +static UiList *menu_list; +int new_item_count = 0; + +void action_add_menu_item(UiEvent *event, void *userdata) { + char str[64]; + snprintf(str, 64, "new item %d", new_item_count++); + + ui_list_append(menu_list, strdup(str)); + ui_list_notify(menu_list); +} + +void action_menu_list(UiEvent *event, void *userdata) { + printf("menu list item: %d\n", event->intval); +} + +static int tab_x = 0; +void action_tab2_button(UiEvent *event, void *userdata) { + MyDocument *doc = event->document; + printf("current page: %d\n", (int)ui_get(doc->tabview)); + ui_set(doc->tabview, 0); +} + + +void action_group1(UiEvent *event, void *userdata) { + UiContext *ctx = event->obj->ctx; + if(userdata) { + ui_unset_group(ctx, 1); + } else { + ui_set_group(ctx, 1); + } +} + +void action_group2(UiEvent *event, void *userdata) { + UiContext *ctx = event->obj->ctx; + if(userdata) { + ui_unset_group(ctx, 2); + } else { + ui_set_group(ctx, 2); + } +} + +static UiObject *ref_window; + +void action_button_ref(UiEvent *event, void *userdata) { + UiObject *obj = event->obj; + printf("action_button_ref: %u\n", obj->ref); + ui_object_ref(obj); + ref_window = obj; +} + +void action_button_unref(UiEvent *event, void *userdata) { + UiObject *obj = userdata; + printf("action_button_unref: %u\n", obj->ref); + ui_object_unref(obj); +} + +void action_toolbar_unrefwindow(UiEvent *event, void *userdata) { + UiObject *obj = ui_simple_window("Unref", NULL); + ui_grid(obj, .margin = 20) { + ui_button(obj, .label = "Unref", .onclick = action_button_unref, .onclickdata = ref_window); + } + ui_show(obj); +} + +void action_sourcelist_activate(UiEvent *event, void *userdata) { + printf("sourcelist %s index %d\n", event->eventdata, event->intval); +} + +UiMenuBuilder *menubuilder; + +void* table_getvalue(void *row, int col) { + return row; +} + +void sourcelist_getvalue(void *sublistdata, void *rowdata, int index, UiSubListItem *item) { + item->label = strdup(rowdata); + item->eventdata = sublistdata; +} + +typedef struct Item { + UiObject *obj; + MyDocument *doc; + void *elm; +} Item; + +void item_remove(UiEvent *event, void *userdata) { + Item *item = userdata; + int index = 0; + void *elm = ui_list_first(item->doc->items); + while(elm) { + if(elm == item->elm) { + break; + } + elm = ui_list_next(item->doc->items); + index++; + } + + ui_list_remove(item->doc->items, index); + ui_list_update(item->doc->items); +} + +void create_item(UiObject *obj, int index, void *elm, void *userdata) { + Item *i = ui_malloc(obj->ctx, sizeof(Item)); + i->obj = obj; + i->elm = elm; + i->doc = userdata; + + char *item = elm; + ui_button(obj, .label = item); + ui_checkbox(obj, .label = "Check"); + ui_label(obj, .fill = UI_ON); + ui_button(obj, .label = "X", .onclick = item_remove, .onclickdata = i); + + + +} + void application_startup(UiEvent *event, void *data) { + // global list + UiContext *global = ui_global_context(); + menu_list = ui_list_new(global, "menulist"); + ui_list_append(menu_list, "menu list item 1"); + ui_list_append(menu_list, "menu list item 2"); + ui_list_append(menu_list, "menu list item 3"); - UiObject *obj = ui_window("Test", NULL); - ui_textarea_nv(obj, "text"); - ui_button(obj, "Test", action_button, NULL); - ui_button(obj, "Switch Document", action_switch, NULL); + + + UiObject *obj = ui_sidebar_window("Test", NULL); + + MyDocument *doc = create_doc(); + ui_attach_document(obj->ctx, doc); + + ui_sidebar(obj, .margin = 0, .spacing = 0) { + ui_sourcelist(obj, .fill = UI_ON, + .getvalue = sourcelist_getvalue, + .sublists = UI_SUBLISTS(UI_SUBLIST(.varname = "srclist1", .header = "Header 1", .userdata = "Sublist1"), UI_SUBLIST(.varname = "srclist2", .header = "Header 2", .userdata = "Sublist2")), + .onactivate = action_sourcelist_activate); + } - doc1 = create_doc(); - doc2 = create_doc(); + ui_tabview(obj, .spacing=10, .margin=10, .tabview = UI_TABVIEW_NAVIGATION_SIDE, .varname="tabview") { + ui_tab(obj, "Tab 1") { + ui_vbox(obj, .fill = UI_OFF, .margin = 15, .spacing = 15) { + ui_button(obj, .label = "Test Button", .icon = "application-x-generic", .onclick = action_button); + ui_togglebutton(obj, .label = "Toggle"); + ui_checkbox(obj, .label = "My Checkbox"); + } + ui_grid(obj, .fill = UI_OFF, .columnspacing = 15, .rowspacing = 15, .margin = 15) { + ui_button(obj, .label = "Activate Group 1", .hexpand = TRUE, .onclick = action_group1); + ui_button(obj, .label = "Disable Group 1", .onclick = action_group1, .onclickdata = "disable"); + ui_newline(obj); + ui_button(obj, .label = "Activate Group 2", .hexpand = TRUE, .onclick = action_group2); + ui_button(obj, .label = "Disable Group 2", .onclick = action_group2, .onclickdata = "disable"); + ui_newline(obj); + + ui_button(obj, .label = "Groups 1,2", .colspan = 2, .groups = UI_GROUPS(1, 2)); + ui_newline(obj); + + ui_label(obj, .label = "Label Col 1", .align = UI_ALIGN_LEFT); + ui_label(obj, .label = "Label Col 2", .style = UI_LABEL_STYLE_TITLE, .align = UI_ALIGN_RIGHT); + ui_newline(obj); + + ui_spinner(obj, .step = 5); + ui_newline(obj); + + ui_progressbar(obj, .colspan = 2, .varname = "progress"); + ui_set(doc->progress, 0.75); + ui_newline(obj); + + ui_textfield(obj, .value = doc->str1); + ui_newline(obj); + + //ui_button(obj, .label="Test"); + ui_path_textfield(obj, .varname = "path", .hfill = TRUE, .hexpand = TRUE); + ui_set(doc->path, "/test/path/longdirectoryname/123"); + ui_newline(obj); + + //UiModel *model = ui_model(obj->ctx, UI_ICON_TEXT, "Col 1", UI_STRING, "Col 2", -1); + //model->getvalue = list_getvalue; + ui_combobox(obj, .hexpand = true, .vexpand = false, .colspan = 2, .varname = "list", .getvalue = list_getvalue); + ui_newline(obj); + + ui_hbox0(obj) { + ui_radiobutton(obj, .label = "Radio 1", .varname = "radio"); + ui_radiobutton(obj, .label = "Radio 2", .varname = "radio"); + ui_radiobutton(obj, .label = "Radio 3", .varname = "radio"); + } + ui_newline(obj); + + UiModel *model = ui_model(obj->ctx, UI_STRING, "col1", -1); + model->getvalue = table_getvalue; + ui_table(obj, .model = model, .list = doc->list2, .colspan = 2, .hexpand = TRUE, .contextmenu = menubuilder); + } + } + ui_tab(obj, "Tab 2") { + ui_button(obj, .label = "Button 1 Start Thread", .onclick=action_start_thread); + ui_button(obj, .label = "Button 2 Notify Thread", .onclick=action_notify_thread); + ui_button(obj, .label = "Obj Ref", .onclick=action_button_ref); + ui_button(obj, .label = "Obj Unref", .onclick=action_button_unref, .onclickdata = obj); + ui_button(obj, .label = "Button 5", .onclick=action_tab2_button); + ui_button(obj, .label = "Button 6", .onclick=action_tab2_button); + } + ui_tab(obj, "Tab 3") { + UiTabViewArgs args = {0}; + UI_CTN(obj, tabview=ui_tabview_create(obj, args)) { + UiObject *tab1 = ui_tabview_add(tabview, "Sub 1", -1); + ui_button(tab1, .label = "Button 1"); + + + UiObject *tab2 = ui_tabview_add(tabview, "Sub 2", -1); + ui_button(tab2, .label = "Button 2"); + } + } + ui_tab(obj, "Tab 4") { + ui_textarea(obj, .varname = "text"); + } + ui_tab(obj, "Tab 5") { + ui_button(obj, .label = "Test Button", .icon = "application-x-generic", .onclick = action_button); + ui_imageviewer(obj, .varname = "image", .style_class = "imageviewer", .contextmenu = menubuilder); + } + + ui_tab(obj, "Tab 6") { + ui_scrolledwindow(obj, .fill = UI_ON) { + ui_expander(obj, .label = "Expander", .margin = 10, .spacing = 10) { + ui_label(obj, .label = "Test"); + ui_button(obj, .label = "Button"); + } + + ui_frame(obj, .label = "Frame", .margin = 10, .spacing = 10) { + ui_label(obj, .label = "Title", .style = UI_LABEL_STYLE_TITLE); + ui_label(obj, .label = "Sub-Title", .style = UI_LABEL_STYLE_SUBTITLE); + ui_label(obj, .label = "Dim Label", .style = UI_LABEL_STYLE_DIM); + ui_label(obj, .label = "No Style"); + } + + for(int i=0;i<100;i++) { + char labelstr[32]; + snprintf(labelstr, 32, "button %d", i); + ui_button(obj, .label = labelstr); + } + } + } + + ui_tab(obj, "Tab 7") { + ui_itemlist(obj, .create_ui = create_item, .varname = "items", .subcontainer = UI_CONTAINER_HBOX, .sub_spacing = 10, .margin = 10, .spacing = 4, .userdata = doc); + } + } - ui_attach_document(obj->ctx, doc1); + /* + + */ ui_show(obj); } @@ -93,18 +464,176 @@ ui_onstartup(application_startup, NULL); // menu - ui_menu("_File"); - ui_menuitem("_Hello", action_menu, NULL); - ui_submenu("Submenu1"); - ui_submenu("Submenu2"); - ui_menuitem("item2", action_menu, NULL); - ui_submenu_end(); - ui_menuitem("item3", action_menu, NULL); - ui_submenu_end(); - ui_menuitem("item4", action_menu, NULL); - + ui_menu("File") { + ui_menuitem(.label = "Test"); + } + + ui_contextmenu(&menubuilder) { + ui_menuitem(.label = "Context Item 1"); + ui_menuitem(.label = "Context Item 2"); + ui_menu("Context Submenu") { + ui_menuitem(.label = "Context Sub Item"); + } + } + + ui_menu("Edit") { + ui_menuitem(.label = "Undo"); + ui_menuseparator(); + ui_menu("Submenu") { + ui_menuitem(.label = "Subitem"); + } + } + + ui_toolbar_item("Test", .label = "Test", .onclick = action_toolbar_button); + ui_toolbar_item("Test2", .label = "New Window", .onclick = action_toolbar_newwindow); + ui_toolbar_item("Test3", .label = "Dialog", .onclick = action_toolbar_dialog); + ui_toolbar_item("Test4", .label = "Unref Window", .onclick = action_toolbar_unrefwindow); + ui_toolbar_item("Test5", .label = "Test 5", .onclick = action_toolbar_button); + ui_toolbar_item("Test6", .label = "Test 6", .onclick = action_toolbar_button); + ui_toolbar_toggleitem("Toggle", .label = "Toggle", .onchange = action_toolbar_button); + ui_toolbar_menu("Menu", .label = "Menu") { + ui_menuitem("Secondary Test", .onclick = action_toolbar_button, NULL); + ui_menu("Secondary Sub") { + ui_menuitem("Secondary subitem", NULL, NULL); + } + ui_menuseparator(); + ui_menu_itemlist(.varname = "menulist", .onselect=action_menu_list); + ui_menuseparator(); + ui_menuitem("last", .onclick = action_add_menu_item); + } + + ui_toolbar_appmenu() { + ui_menuitem("New"); + ui_menuitem("Open"); + ui_menuitem("Save"); + + ui_menuseparator(); + + ui_menuitem("Close"); + } + + ui_toolbar_add_default("Test", UI_TOOLBAR_LEFT); + ui_toolbar_add_default("Test6", UI_TOOLBAR_LEFT); + ui_toolbar_add_default("Toggle", UI_TOOLBAR_LEFT); + ui_toolbar_add_default("Menu", UI_TOOLBAR_LEFT); + + ui_toolbar_add_default("Test2", UI_TOOLBAR_CENTER); + ui_toolbar_add_default("Test3", UI_TOOLBAR_CENTER); + + ui_toolbar_add_default("Test4", UI_TOOLBAR_RIGHT); + ui_toolbar_add_default("Test5", UI_TOOLBAR_RIGHT); ui_main(); return (EXIT_SUCCESS); } + +#endif + +#if defined(UI_COCOA) || defined(UI_MOTIF) + +static UiList *menulist; +int items = 4; + +void action_button(UiEvent *event, void *data) { + printf("action_button\n"); + + char *newitem = malloc(32); + snprintf(newitem, 32, "Item %d", ++items); + ui_list_append(menulist, newitem); + ui_list_notify(menulist); +} + +typedef struct WData { + UiString *path; + UiList *list; +} WData; + + +int lsitems = 4; + +void action_button2(UiEvent *event, void *data) { + WData *wdata = event->window; + char *newitem = malloc(32); + snprintf(newitem, 32, "List Item %d", ++lsitems); + ui_list_append(wdata->list, newitem); + ui_list_update(wdata->list); + UiListSelection sel; + int index = lsitems-1; + sel.count = 1; + sel.rows = &index; + wdata->list->setselection(wdata->list, sel); +} + +void action_listevent(UiEvent *event, void *data) { + printf("%s: %d\n", data, event->intval); + UiListSelection *sel = event->eventdata; + for(int i=0;icount;i++) { + printf("sel: %d\n", sel->rows[i]); + } + printf("\n"); +} + +void application_startup(UiEvent *event, void *data) { + + menulist = ui_list_new(ui_global_context(), "menulist"); + ui_list_append(menulist, "Item 1"); + ui_list_append(menulist, "Item 2"); + ui_list_append(menulist, "Item 3"); + ui_list_append(menulist, "Item 4"); + + UiObject *obj = ui_window("Test", NULL); + + WData *wdata = ui_malloc(obj->ctx, sizeof(WData)); + wdata->path = ui_string_new(obj->ctx, NULL); + wdata->list = ui_list_new(obj->ctx, NULL); + obj->window = wdata; + + ui_list_append(wdata->list, "List Item 1"); + ui_list_append(wdata->list, "List Item 2"); + ui_list_append(wdata->list, "List Item 3"); + ui_list_append(wdata->list, "List Item 4"); + + ui_button(obj, .label = "Add Menu Item", .onclick = action_button, .name = "mybutton1"); + ui_button(obj, .label = "Add List Item", .onclick = action_button2); + ui_progressbar(obj, .name = "pb"); + ui_listview(obj, .list = wdata->list, .fill = UI_ON, .multiselection = TRUE, + .onactivate = action_listevent, .onactivatedata = "activate", + .onselection = action_listevent, .onselectiondata = "selection"); + + + ui_show(obj); +} + +void action_test(UiEvent *event, void *data) { + printf("action test\n"); +} + +int main(int argc, char** argv) { + ui_init("app1", argc, argv); + ui_onstartup(application_startup, NULL); + + // menu + ui_menu("File") { + ui_menuitem(.label = "Test 1", .onclick = action_test); + ui_menuitem(.label = "Test 2", .onclick = action_test); + ui_menuitem(.label = "Test 3", .onclick = action_test); + ui_menuseparator(); + ui_menu_toggleitem(.label = "Toggle 1"); + ui_menu_toggleitem(.label = "Toggle 2"); + ui_menuseparator(); + ui_menu_radioitem(.label = "Radio 1", .varname = "menu_radio"); + ui_menu_radioitem(.label = "Radio 2", .varname = "menu_radio"); + ui_menu_radioitem(.label = "Radio 3", .varname = "menu_radio"); + ui_menu_radioitem(.label = "Radio 4", .varname = "menu_radio"); + ui_menuseparator(); + ui_menu_itemlist(.varname = "menulist"); + ui_menuseparator(); + ui_menuitem(.label = "Quit"); + } + + ui_main(); + return (EXIT_SUCCESS); +} + +#endif diff -r fe49cff3c571 -r bb7da585debc configure --- a/configure Sun May 23 09:44:43 2021 +0200 +++ b/configure Sat Jan 04 16:38:48 2025 +0100 @@ -1,40 +1,53 @@ #!/bin/sh - -PREFIX=/usr -EPREFIX=$PREFIX +# create temporary directory +TEMP_DIR=".tmp-`uname -n`" +rm -Rf "$TEMP_DIR" +if mkdir -p "$TEMP_DIR"; then + : +else + echo "Cannot create tmp dir $TEMP_DIR" + echo "Abort" + exit 1 +fi +touch "$TEMP_DIR/options" +touch "$TEMP_DIR/features" -BINDIR= -SBINDIR= -LIBDIR= -LIBEXECDIR= -DATADIR= -SYSCONFDIR= -SHAREDSTATEDIR= -LOCALSTATEDIR= -INCLUDEDIR= -INFODIR= -MANDIR= +# define standard variables +# also define standard prefix (this is where we will search for config.site) +prefix=/usr +exec_prefix= +bindir= +sbindir= +libdir= +libexecdir= +datarootdir= +datadir= +sysconfdir= +sharedstatedir= +localstatedir= +runstatedir= +includedir= +infodir= +localedir= +mandir= -OS=`uname -s` -OS_VERSION=`uname -r` - -TEMP_DIR=".tmp-`uname -n`" -mkdir -p $TEMP_DIR -if [ $? -ne 0 ]; then - echo "Cannot create tmp dir" - echo "Abort" -fi -touch $TEMP_DIR/options -touch $TEMP_DIR/features +# custom variables # features +# clean abort +abort_configure() +{ + rm -Rf "$TEMP_DIR" + exit 1 +} + # help text printhelp() { - echo "Usage: $0 [OPTIONS]..." - cat << __EOF__ + echo "Usage: $0 [OPTIONS]..." + cat << __EOF__ Installation directories: --prefix=PREFIX path prefix for architecture-independent files [/usr] @@ -47,697 +60,846 @@ --sysconfdir=DIR system configuration files [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --runstatedir=DIR run-time variable data [LOCALSTATEDIR/run] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] --datadir=DIR read-only architecture-independent data [DATAROOTDIR] --infodir=DIR info documentation [DATAROOTDIR/info] --mandir=DIR man documentation [DATAROOTDIR/man] + --localedir=DIR locale-dependent data [DATAROOTDIR/locale] Options: - --toolkit=(gtk3|gtk2|gtk2legacy|qt5|qt4|motif) + --debug add extra compile flags for debug builds + --release add extra compile flags for release builds + --toolkit=(libadwaita|gtk4|gtk3|gtk2|gtk2legacy|qt5|qt4|cocoa|motif) __EOF__ } # -# parse arguments +# parse arguments # -for ARG in $@ +BUILD_TYPE="default" +for ARG in "$@" do case "$ARG" in - "--prefix="*) PREFIX=${ARG#--prefix=} ;; - "--exec-prefix="*) EPREFIX=${ARG#--exec-prefix=} ;; - "--bindir="*) BINDIR=${ARG#----bindir=} ;; - "--sbindir="*) SBINDIR=${ARG#--sbindir=} ;; - "--libdir="*) LIBDIR=${ARG#--libdir=} ;; - "--libexecdir="*) LIBEXECDIR=${ARG#--libexecdir=} ;; - "--datadir="*) DATADIR=${ARG#--datadir=} ;; - "--sysconfdir="*) SYSCONFDIR=${ARG#--sysconfdir=} ;; - "--sharedstatedir="*) SHAREDSTATEDIR=${ARG#--sharedstatedir=} ;; - "--localstatedir="*) LOCALSTATEDIR=${ARG#--localstatedir=} ;; - "--includedir="*) INCLUDEDIR=${ARG#--includedir=} ;; - "--infodir="*) INFODIR=${ARG#--infodir=} ;; - "--mandir"*) MANDIR=${ARG#--mandir} ;; - "--help"*) printhelp; exit 1 ;; - "--toolkit="*) OPT_TOOLKIT=${ARG#--toolkit=} ;; - "-"*) echo "unknown option: $ARG"; exit 1 ;; - esac + "--prefix="*) prefix=${ARG#--prefix=} ;; + "--exec-prefix="*) exec_prefix=${ARG#--exec-prefix=} ;; + "--bindir="*) bindir=${ARG#----bindir=} ;; + "--sbindir="*) sbindir=${ARG#--sbindir=} ;; + "--libdir="*) libdir=${ARG#--libdir=} ;; + "--libexecdir="*) libexecdir=${ARG#--libexecdir=} ;; + "--datarootdir="*) datarootdir=${ARG#--datarootdir=} ;; + "--datadir="*) datadir=${ARG#--datadir=} ;; + "--sysconfdir="*) sysconfdir=${ARG#--sysconfdir=} ;; + "--sharedstatedir="*) sharedstatedir=${ARG#--sharedstatedir=} ;; + "--localstatedir="*) localstatedir=${ARG#--localstatedir=} ;; + "--includedir="*) includedir=${ARG#--includedir=} ;; + "--infodir="*) infodir=${ARG#--infodir=} ;; + "--mandir"*) mandir=${ARG#--mandir} ;; + "--localedir"*) localedir=${ARG#--localedir} ;; + "--help"*) printhelp; abort_configure ;; + "--debug") BUILD_TYPE="debug" ;; + "--release") BUILD_TYPE="release" ;; + "--toolkit="*) OPT_TOOLKIT=${ARG#--toolkit=} ;; + "-"*) echo "unknown option: $ARG"; abort_configure ;; + esac done -# set dir variables -if [ -z "$BINDIR" ]; then - BINDIR=$EPREFIX/bin -fi -if [ -z "$SBINDIR" ]; then - SBINDIR=$EPREFIX/sbin -fi -if [ -z "$LIBDIR" ]; then - LIBDIR=$EPREFIX/lib -fi -if [ -z "$LIBEXEC" ]; then - LIBEXECDIR=$EPREFIX/libexec -fi -if [ -z "$DATADIR" ]; then - DATADIR=$PREFIX/share -fi -if [ -z "$SYSCONFDIR" ]; then - SYSCONFDIR=$PREFIX/etc -fi -if [ -z "$SHAREDSTATEDIR" ]; then - SHAREDSTATEDIR=$PREFIX/com -fi -if [ -z "$LOCALSTATEDIR" ]; then - LOCALSTATEDIR=$PREFIX/var -fi -if [ -z "$INCLUDEDIR" ]; then - INCLUDEDIR=$PREFIX/include -fi -if [ -z "$INFODIR" ]; then - INFODIR=$PREFIX/info -fi -if [ -z "$MANDIR" ]; then - MANDIR=$PREFIX/man + + +# set defaults for dir variables +: ${exec_prefix:="$prefix"} +: ${bindir:='${exec_prefix}/bin'} +: ${sbindir:='${exec_prefix}/sbin'} +: ${libdir:='${exec_prefix}/lib'} +: ${libexecdir:='${exec_prefix}/libexec'} +: ${datarootdir:='${prefix}/share'} +: ${datadir:='${datarootdir}'} +: ${sysconfdir:='${prefix}/etc'} +: ${sharedstatedir:='${prefix}/com'} +: ${localstatedir:='${prefix}/var'} +: ${runstatedir:='${localstatedir}/run'} +: ${includedir:='${prefix}/include'} +: ${infodir:='${datarootdir}/info'} +: ${mandir:='${datarootdir}/man'} +: ${localedir:='${datarootdir}/locale'} + +# check if a config.site exists and load it +if [ -n "$CONFIG_SITE" ]; then + # CONFIG_SITE may contain space separated file names + for cs in $CONFIG_SITE; do + printf "loading defaults from $cs... " + . "$cs" + echo ok + done +elif [ -f "$prefix/share/config.site" ]; then + printf "loading site defaults... " + . "$prefix/share/config.site" + echo ok +elif [ -f "$prefix/etc/config.site" ]; then + printf "loading site defaults... " + . "$prefix/etc/config.site" + echo ok fi -which pkg-config > /dev/null -if [ $? -eq 0 ]; then - PKG_CONFIG=pkg-config -else - PKG_CONFIG=false -fi +# Test for availability of pkg-config +PKG_CONFIG=`command -v pkg-config` +: ${PKG_CONFIG:="false"} # Simple uname based platform detection # $PLATFORM is used for platform dependent dependency selection +OS=`uname -s` +OS_VERSION=`uname -r` printf "detect platform... " -if [ $OS = SunOS ]; then +if [ "$OS" = "SunOS" ]; then PLATFORM="solaris sunos unix svr4" -fi -if [ $OS = Linux ]; then +elif [ "$OS" = "Linux" ]; then PLATFORM="linux unix" -fi -if [ $OS = FreeBSD ]; then +elif [ "$OS" = "FreeBSD" ]; then PLATFORM="freebsd bsd unix" -fi -if [ $OS = Darwin ]; then +elif [ "$OS" = "OpenBSD" ]; then + PLATFORM="openbsd bsd unix" +elif [ "$OS" = "NetBSD" ]; then + PLATFORM="netbsd bsd unix" +elif [ "$OS" = "Darwin" ]; then PLATFORM="macos osx bsd unix" -fi -echo $OS | grep "MINGW" > /dev/null -if [ $? -eq 0 ]; then +elif echo "$OS" | grep -i "MINGW" > /dev/null; then PLATFORM="windows mingw" fi - -if [ -z "$PLATFORM" ]; then - PLATFORM="unix" -fi +: ${PLATFORM:="unix"} -for p in $PLATFORM -do - PLATFORM_NAME=$p - break -done -echo $PLATFORM_NAME +PLATFORM_NAME=`echo "$PLATFORM" | cut -f1 -d' ' -` +echo "$PLATFORM_NAME" isplatform() { for p in $PLATFORM do - if [ $p = $1 ]; then + if [ "$p" = "$1" ]; then return 0 fi done return 1 } -isnotplatform() +notisplatform() { for p in $PLATFORM do - if [ $p = $1 ]; then + if [ "$p" = "$1" ]; then + return 1 + fi + done + return 0 +} +istoolchain() +{ + for t in $TOOLCHAIN + do + if [ "$t" = "$1" ]; then + return 0 + fi + done + return 1 +} +notistoolchain() +{ + for t in $TOOLCHAIN + do + if [ "$t" = "$1" ]; then return 1 fi done return 0 } -# generate config.mk and config.h -cat > $TEMP_DIR/config.mk << __EOF__ -# -# config.mk generated by configure -# -# general vars - -PREFIX=$PREFIX -EPREFIX=$EPREFIX - -BINDIR=$BINDIR -SBINDIR=$SBINDIR -LIBDIR=$LIBDIR -LIBEXECDIR=$LIBEXECDIR -DATADIR=$DATADIR -SYSCONFDIR=$SYSCONFDIR -SHAREDSTATEDIR=$SHAREDSTATEDIR -LOCALSTATEDIR=$LOCALSTATEDIR -INCLUDEDIR=$INCLUDEDIR -INFODIR=$INFODIR -MANDIR=$MANDIR - +# generate vars.mk +cat > "$TEMP_DIR/vars.mk" << __EOF__ +prefix=$prefix +exec_prefix=$exec_prefix +bindir=$bindir +sbindir=$sbindir +libdir=$libdir +libexecdir=$libexecdir +datarootdir=$datarootdir +datadir=$datadir +sysconfdir=$sysconfdir +sharedstatedir=$sharedstatedir +localstatedir=$localstatedir +runstatedir=$runstatedir +includedir=$includedir +infodir=$infodir +mandir=$mandir +localedir=$localedir __EOF__ -echo > $TEMP_DIR/make.mk - -ENV_CFLAGS=$CFLAGS -ENV_LDFLAGS=$LDFLAGS -ENV_CXXFLAGS=$CXXFLAGS - -# Toolchain detection -# this will insert make vars to config.mk +# toolchain detection utilities . make/toolchain.sh -# add user specified flags to config.mk -echo >> $TEMP_DIR/config.mk -if [ ! -z "${ENV_CFLAGS}" ]; then - echo "CFLAGS += $ENV_CFLAGS" >> $TEMP_DIR/config.mk -fi -if [ ! -z "${ENV_CXXFLAGS}" ]; then - echo "CXXFLAGS += $ENV_CXXFLAGS" >> $TEMP_DIR/config.mk -fi -if [ ! -z "${ENV_LDFLAGS}" ]; then - echo "LDFLAGS += $ENV_LDFLAGS" >> $TEMP_DIR/config.mk -fi - # # DEPENDENCIES # -dependency_qt4() +# check languages +lang_c= +lang_cpp= +if detect_c_compiler ; then + lang_c=1 +fi + +# create buffer for make variables required by dependencies +echo > "$TEMP_DIR/make.mk" + +test_pkg_config() { - printf "checking for qt4... " - # dependency qt4 - while true - do - qmake-qt4 -o - /dev/null | grep DEFINES\ > /dev/null - if [ $? -eq 0 ]; then - CFLAGS="$CFLAGS `qmake-qt4 -o - /dev/null | grep DEFINES\ `" - else - break - fi - qmake-qt4 -o - /dev/null | grep INCPATH\ > /dev/null - if [ $? -eq 0 ]; then - CFLAGS="$CFLAGS `qmake-qt4 -o - /dev/null | grep INCPATH\ `" - else - break - fi - > /dev/null - if [ $? -eq 0 ]; then - LDFLAGS="$LDFLAGS ``" - else - break - fi - which qmake-qt4 > /dev/null - if [ $? -ne 0 ]; then - break - fi - echo yes - return 0 - done - - echo no - return 1 + if "$PKG_CONFIG" --exists "$1" ; then : + else return 1 ; fi + if [ -z "$2" ] || "$PKG_CONFIG" --atleast-version="$2" "$1" ; then : + else return 1 ; fi + if [ -z "$3" ] || "$PKG_CONFIG" --exact-version="$3" "$1" ; then : + else return 1 ; fi + if [ -z "$4" ] || "$PKG_CONFIG" --max-version="$4" "$1" ; then : + else return 1 ; fi + return 0 } -dependency_gtk2legacy() + +print_check_msg() { - printf "checking for gtk2legacy... " - # dependency gtk2legacy + if [ -z "$1" ]; then + shift + printf "$@" + fi +} + +dependency_error_gtk2legacy() +{ + print_check_msg "$dep_checked_gtk2legacy" "checking for gtk2legacy... " + # dependency gtk2legacy while true do if [ -z "$PKG_CONFIG" ]; then - break + break fi - $PKG_CONFIG gtk+-2.0 - if [ $? -ne 0 ] ; then + if test_pkg_config "gtk+-2.0" "" "" "" ; then + TEMP_CFLAGS="$TEMP_CFLAGS `"$PKG_CONFIG" --cflags gtk+-2.0`" + TEMP_LDFLAGS="$TEMP_LDFLAGS `"$PKG_CONFIG" --libs gtk+-2.0`" + else break fi - CFLAGS="$CFLAGS `$PKG_CONFIG --cflags gtk+-2.0`" - LDFLAGS="$LDFLAGS `$PKG_CONFIG --libs gtk+-2.0`" - CFLAGS="$CFLAGS -DUI_GTK2 -DUI_GTK2LEGACY" - LDFLAGS="$LDFLAGS -lpthread" - echo yes - return 0 + TEMP_CFLAGS="$TEMP_CFLAGS -DUI_GTK2 -DUI_GTK2LEGACY" + TEMP_LDFLAGS="$TEMP_LDFLAGS -lpthread" + print_check_msg "$dep_checked_gtk2legacy" "yes\n" + dep_checked_gtk2legacy=1 + return 1 done - - echo no - return 1 + + print_check_msg "$dep_checked_gtk2legacy" "no\n" + dep_checked_gtk2legacy=1 + return 0 } -dependency_qt5() +dependency_error_gtk2() { - printf "checking for qt5... " - # dependency qt5 + print_check_msg "$dep_checked_gtk2" "checking for gtk2... " + # dependency gtk2 while true do - qmake-qt5 -o - /dev/null | grep DEFINES\ > /dev/null - if [ $? -eq 0 ]; then - CFLAGS="$CFLAGS `qmake-qt5 -o - /dev/null | grep DEFINES\ `" + if [ -z "$PKG_CONFIG" ]; then + break + fi + if pkg-config --atleast-version=2.20 gtk+-2.0 > /dev/null ; then + : + else + break + fi + if test_pkg_config "gtk+-2.0" "" "" "" ; then + TEMP_CFLAGS="$TEMP_CFLAGS `"$PKG_CONFIG" --cflags gtk+-2.0`" + TEMP_LDFLAGS="$TEMP_LDFLAGS `"$PKG_CONFIG" --libs gtk+-2.0`" else break fi - qmake-qt5 -o - /dev/null | grep INCPATH\ > /dev/null - if [ $? -eq 0 ]; then - CFLAGS="$CFLAGS `qmake-qt5 -o - /dev/null | grep INCPATH\ `" - else + TEMP_CFLAGS="$TEMP_CFLAGS -DUI_GTK2" + TEMP_LDFLAGS="$TEMP_LDFLAGS -lpthread" + print_check_msg "$dep_checked_gtk2" "yes\n" + dep_checked_gtk2=1 + return 1 + done + + print_check_msg "$dep_checked_gtk2" "no\n" + dep_checked_gtk2=1 + return 0 +} +dependency_error_gtk3() +{ + print_check_msg "$dep_checked_gtk3" "checking for gtk3... " + # dependency gtk3 + while true + do + if [ -z "$PKG_CONFIG" ]; then break fi - > /dev/null - if [ $? -eq 0 ]; then - LDFLAGS="$LDFLAGS ``" + if test_pkg_config "gtk+-3.0" "" "" "" ; then + TEMP_CFLAGS="$TEMP_CFLAGS `"$PKG_CONFIG" --cflags gtk+-3.0`" + TEMP_LDFLAGS="$TEMP_LDFLAGS `"$PKG_CONFIG" --libs gtk+-3.0`" else break fi - which qmake-qt5 > /dev/null - if [ $? -ne 0 ]; then - break - fi - echo yes - return 0 + TEMP_CFLAGS="$TEMP_CFLAGS -DUI_GTK3" + TEMP_LDFLAGS="$TEMP_LDFLAGS -lpthread" + print_check_msg "$dep_checked_gtk3" "yes\n" + dep_checked_gtk3=1 + return 1 done - - echo no - return 1 + + print_check_msg "$dep_checked_gtk3" "no\n" + dep_checked_gtk3=1 + return 0 } -dependency_gtk2() +dependency_error_gtk4() { - printf "checking for gtk2... " - # dependency gtk2 + print_check_msg "$dep_checked_gtk4" "checking for gtk4... " + # dependency gtk4 while true do if [ -z "$PKG_CONFIG" ]; then - break + break fi - $PKG_CONFIG gtk+-2.0 - if [ $? -ne 0 ] ; then + if test_pkg_config "gtk4" "" "" "" ; then + TEMP_CFLAGS="$TEMP_CFLAGS `"$PKG_CONFIG" --cflags gtk4`" + TEMP_LDFLAGS="$TEMP_LDFLAGS `"$PKG_CONFIG" --libs gtk4`" + else break fi - CFLAGS="$CFLAGS `$PKG_CONFIG --cflags gtk+-2.0`" - LDFLAGS="$LDFLAGS `$PKG_CONFIG --libs gtk+-2.0`" - CFLAGS="$CFLAGS -DUI_GTK2" - LDFLAGS="$LDFLAGS -lpthread" - pkg-config --atleast-version=2.20 gtk+-2.0 > /dev/null - if [ $? -ne 0 ]; then - break - fi - echo yes - return 0 + TEMP_CFLAGS="$TEMP_CFLAGS -DUI_GTK4" + TEMP_LDFLAGS="$TEMP_LDFLAGS -lpthread" + print_check_msg "$dep_checked_gtk4" "yes\n" + dep_checked_gtk4=1 + return 1 done - - echo no - return 1 + + print_check_msg "$dep_checked_gtk4" "no\n" + dep_checked_gtk4=1 + return 0 } -dependency_gtk3() +dependency_error_libadwaita() { - printf "checking for gtk3... " - # dependency gtk3 + print_check_msg "$dep_checked_libadwaita" "checking for libadwaita... " + # dependency libadwaita while true do if [ -z "$PKG_CONFIG" ]; then - break + break fi - $PKG_CONFIG gtk+-3.0 - if [ $? -ne 0 ] ; then + if test_pkg_config "libadwaita-1" "" "" "" ; then + TEMP_CFLAGS="$TEMP_CFLAGS `"$PKG_CONFIG" --cflags libadwaita-1`" + TEMP_LDFLAGS="$TEMP_LDFLAGS `"$PKG_CONFIG" --libs libadwaita-1`" + else break fi - CFLAGS="$CFLAGS `$PKG_CONFIG --cflags gtk+-3.0`" - LDFLAGS="$LDFLAGS `$PKG_CONFIG --libs gtk+-3.0`" - CFLAGS="$CFLAGS -DUI_GTK3" - LDFLAGS="$LDFLAGS -lpthread" - echo yes - return 0 + TEMP_CFLAGS="$TEMP_CFLAGS -DUI_GTK4 -DUI_LIBADWAITA" + TEMP_LDFLAGS="$TEMP_LDFLAGS -lpthread" + print_check_msg "$dep_checked_libadwaita" "yes\n" + dep_checked_libadwaita=1 + return 1 done - - echo no - return 1 + + print_check_msg "$dep_checked_libadwaita" "no\n" + dep_checked_libadwaita=1 + return 0 } -dependency_motif() +dependency_error_motif() { - printf "checking for motif... " - # dependency motif + print_check_msg "$dep_checked_motif" "checking for motif... " + # dependency motif platform="bsd" while true do - CFLAGS="$CFLAGS -DUI_MOTIF" - LDFLAGS="$LDFLAGS -lXm -lXt -lX11 -lpthread" - echo yes - return 0 + if notisplatform "bsd"; then + break + fi + TEMP_CFLAGS="$TEMP_CFLAGS -DUI_MOTIF -I/usr/local/include/X11" + TEMP_LDFLAGS="$TEMP_LDFLAGS -lXm -lXt -lX11 -lpthread" + print_check_msg "$dep_checked_motif" "yes\n" + dep_checked_motif=1 + return 1 done - - echo no - return 1 -} -dependency_wpf() -{ - printf "checking for wpf... " - # dependency wpf platform="windows" + + # dependency motif while true do - if isnotplatform "windows"; then - break - fi - CFLAGS="$CFLAGS -DUI_WPF" - echo yes - return 0 + TEMP_CFLAGS="$TEMP_CFLAGS -DUI_MOTIF" + TEMP_LDFLAGS="$TEMP_LDFLAGS -lXm -lXt -lX11 -lpthread" + print_check_msg "$dep_checked_motif" "yes\n" + dep_checked_motif=1 + return 1 done - - echo no - return 1 + + print_check_msg "$dep_checked_motif" "no\n" + dep_checked_motif=1 + return 0 } -dependency_cocoa() +dependency_error_cocoa() { - printf "checking for cocoa... " + print_check_msg "$dep_checked_cocoa" "checking for cocoa... " # dependency cocoa platform="macos" while true do - if isnotplatform "macos"; then + if notisplatform "macos"; then break fi - CFLAGS="$CFLAGS -DUI_COCOA" - LDFLAGS="$LDFLAGS -lobjc -framework Cocoa" - echo yes - return 0 + TEMP_CFLAGS="$TEMP_CFLAGS -DUI_COCOA" + TEMP_LDFLAGS="$TEMP_LDFLAGS -lobjc -framework Cocoa" + print_check_msg "$dep_checked_cocoa" "yes\n" + dep_checked_cocoa=1 + return 1 done - - echo no - return 1 + + print_check_msg "$dep_checked_cocoa" "no\n" + dep_checked_cocoa=1 + return 0 } +dependency_error_winui() +{ + print_check_msg "$dep_checked_winui" "checking for winui... " + # dependency winui platform="windows" + while true + do + if notisplatform "windows"; then + break + fi + TEMP_CFLAGS="$TEMP_CFLAGS -DUI_WINUI" + print_check_msg "$dep_checked_winui" "yes\n" + dep_checked_winui=1 + return 1 + done + + print_check_msg "$dep_checked_winui" "no\n" + dep_checked_winui=1 + return 0 +} + +# start collecting dependency information +echo > "$TEMP_DIR/flags.mk" DEPENDENCIES_FAILED= ERROR=0 -# general dependencies -CFLAGS= -LDFLAGS= +# unnamed dependencies +TEMP_CFLAGS= +TEMP_CXXFLAGS= +TEMP_LDFLAGS= while true do - if isnotplatform "macos"; then + while true + do + if [ -z "$lang_c" ] ; then + ERROR=1 + break + fi + + break + done + break +done +while true +do + if notisplatform "macos"; then break fi while true do - - cat >> $TEMP_DIR/make.mk << __EOF__ -OBJ_EXT = o -LIB_EXT = a + + cat >> "$TEMP_DIR/make.mk" << __EOF__ +OBJ_EXT = .o +LIB_EXT = .a PACKAGE_SCRIPT = package_osx.sh - __EOF__ - break done - break done while true do - if isnotplatform "unix"; then + if notisplatform "unix"; then break fi - if isplatform "macos"; then + if isplatform "macos" || istoolchain "macos"; then break fi while true do - - cat >> $TEMP_DIR/make.mk << __EOF__ -OBJ_EXT = o -LIB_EXT = a + + cat >> "$TEMP_DIR/make.mk" << __EOF__ +OBJ_EXT = .o +LIB_EXT = .a PACKAGE_SCRIPT = package_unix.sh - __EOF__ - break done - + break +done +while true +do + if notisplatform "bsd"; then + break + fi + while true + do + + TEMP_CFLAGS="$TEMP_CFLAGS -I/usr/local/include" + TEMP_LDFLAGS="$TEMP_LDFLAGS -L/usr/local/lib" + break + done break done -# add general dependency flags to config.mk -echo >> $TEMP_DIR/config.mk -if [ ! -z "${CFLAGS}" ]; then - echo "CFLAGS += $CFLAGS" >> $TEMP_DIR/config.mk +# add general dependency flags to flags.mk +echo "# general flags" >> "$TEMP_DIR/flags.mk" +if [ -n "${TEMP_CFLAGS}" ] && [ -n "$lang_c" ]; then + echo "CFLAGS += $TEMP_CFLAGS" >> "$TEMP_DIR/flags.mk" fi -if [ ! -z "${CXXFLAGS}" ]; then - echo "CXXFLAGS += $CXXFLAGS" >> $TEMP_DIR/config.mk +if [ -n "${TEMP_CXXFLAGS}" ] && [ -n "$lang_cpp" ]; then + echo "CXXFLAGS += $TEMP_CXXFLAGS" >> "$TEMP_DIR/flags.mk" fi -if [ ! -z "${LDFLAGS}" ]; then - echo "LDFLAGS += $LDFLAGS" >> $TEMP_DIR/config.mk +if [ -n "${TEMP_LDFLAGS}" ]; then + echo "LDFLAGS += $TEMP_LDFLAGS" >> "$TEMP_DIR/flags.mk" fi # # OPTION VALUES # +checkopt_toolkit_libadwaita() +{ + VERR=0 + if dependency_error_libadwaita ; then + VERR=1 + fi + if [ $VERR -ne 0 ]; then + return 1 + fi + cat >> "$TEMP_DIR/make.mk" << __EOF__ +TOOLKIT = gtk +GTKOBJ = draw_cairo.o +__EOF__ + return 0 +} +checkopt_toolkit_gtk4() +{ + VERR=0 + if dependency_error_gtk4 ; then + VERR=1 + fi + if [ $VERR -ne 0 ]; then + return 1 + fi + cat >> "$TEMP_DIR/make.mk" << __EOF__ +TOOLKIT = gtk +GTKOBJ = draw_cairo.o +__EOF__ + return 0 +} checkopt_toolkit_gtk3() { - VERR=0 - dependency_gtk3 - if [ $? -ne 0 ]; then - VERR=1 - fi - if [ $VERR -ne 0 ]; then - return 1 - fi - cat >> $TEMP_DIR/make.mk << __EOF__ + VERR=0 + if dependency_error_gtk3 ; then + VERR=1 + fi + if [ $VERR -ne 0 ]; then + return 1 + fi + cat >> "$TEMP_DIR/make.mk" << __EOF__ TOOLKIT = gtk GTKOBJ = draw_cairo.o - __EOF__ - return 0 + return 0 } checkopt_toolkit_gtk2() { - VERR=0 - dependency_gtk2 - if [ $? -ne 0 ]; then - VERR=1 - fi - if [ $VERR -ne 0 ]; then - return 1 - fi - cat >> $TEMP_DIR/make.mk << __EOF__ + VERR=0 + if dependency_error_gtk2 ; then + VERR=1 + fi + if [ $VERR -ne 0 ]; then + return 1 + fi + cat >> "$TEMP_DIR/make.mk" << __EOF__ TOOLKIT = gtk GTKOBJ = draw_cairo.o - __EOF__ - return 0 + return 0 } checkopt_toolkit_gtk2legacy() { - VERR=0 - dependency_gtk2legacy - if [ $? -ne 0 ]; then - VERR=1 - fi - if [ $VERR -ne 0 ]; then - return 1 - fi - cat >> $TEMP_DIR/make.mk << __EOF__ + VERR=0 + if dependency_error_gtk2legacy ; then + VERR=1 + fi + if [ $VERR -ne 0 ]; then + return 1 + fi + cat >> "$TEMP_DIR/make.mk" << __EOF__ TOOLKIT = gtk GTKOBJ = draw_gdk.o - __EOF__ - return 0 + return 0 } checkopt_toolkit_qt5() { - VERR=0 - dependency_qt5 - if [ $? -ne 0 ]; then - VERR=1 - fi - if [ $VERR -ne 0 ]; then - return 1 - fi - cat >> $TEMP_DIR/make.mk << __EOF__ + VERR=0 + if dependency_error_qt5 ; then + VERR=1 + fi + if [ $VERR -ne 0 ]; then + return 1 + fi + cat >> "$TEMP_DIR/make.mk" << __EOF__ TOOLKIT = qt LD = $(CXX) - __EOF__ - return 0 + return 0 } checkopt_toolkit_qt4() { - VERR=0 - dependency_qt4 - if [ $? -ne 0 ]; then - VERR=1 - fi - if [ $VERR -ne 0 ]; then - return 1 - fi - cat >> $TEMP_DIR/make.mk << __EOF__ + VERR=0 + if dependency_error_qt4 ; then + VERR=1 + fi + if [ $VERR -ne 0 ]; then + return 1 + fi + cat >> "$TEMP_DIR/make.mk" << __EOF__ TOOLKIT = qt LD = $(CXX) - __EOF__ - return 0 + return 0 +} +checkopt_toolkit_cocoa() +{ + VERR=0 + if dependency_error_cocoa ; then + VERR=1 + fi + if [ $VERR -ne 0 ]; then + return 1 + fi + cat >> "$TEMP_DIR/make.mk" << __EOF__ +TOOLKIT = cocoa +__EOF__ + return 0 } checkopt_toolkit_motif() { - VERR=0 - dependency_motif - if [ $? -ne 0 ]; then - VERR=1 - fi - if [ $VERR -ne 0 ]; then - return 1 - fi - cat >> $TEMP_DIR/make.mk << __EOF__ + VERR=0 + if dependency_error_motif ; then + VERR=1 + fi + if [ $VERR -ne 0 ]; then + return 1 + fi + cat >> "$TEMP_DIR/make.mk" << __EOF__ TOOLKIT = motif - __EOF__ - return 0 + return 0 } # # TARGETS # -CFLAGS= -CXXFLAGS= -LDFLAGS= -# Target: tk -CFLAGS= -LDFLAGS= -CXXFLAGS= +echo >> "$TEMP_DIR/flags.mk" +echo "configuring target: tk" +echo "# flags for target tk" >> "$TEMP_DIR/flags.mk" +TEMP_CFLAGS= +TEMP_CXXFLAGS= +TEMP_LDFLAGS= # Features # Option: --toolkit -if [ -z $OPT_TOOLKIT ]; then - SAVED_ERROR=$ERROR - SAVED_DEPENDENCIES_FAILED=$DEPENDENCIES_FAILED - ERROR=0 - while true - do - if isplatform "windows"; then - checkopt_toolkit_wpf - if [ $? -eq 0 ]; then - echo " toolkit: wpf" >> $TEMP_DIR/options - ERROR=0 - break - fi - fi - if isplatform "macos"; then - checkopt_toolkit_cocoa - if [ $? -eq 0 ]; then - echo " toolkit: cocoa" >> $TEMP_DIR/options - ERROR=0 - break - fi - fi - checkopt_toolkit_gtk3 - if [ $? -eq 0 ]; then - echo " toolkit: gtk3" >> $TEMP_DIR/options - ERROR=0 - break - fi - checkopt_toolkit_qt5 - if [ $? -eq 0 ]; then - echo " toolkit: qt5" >> $TEMP_DIR/options - ERROR=0 - break - fi - checkopt_toolkit_gtk2 - if [ $? -eq 0 ]; then - echo " toolkit: gtk2" >> $TEMP_DIR/options - ERROR=0 - break - fi - checkopt_toolkit_qt4 - if [ $? -eq 0 ]; then - echo " toolkit: qt4" >> $TEMP_DIR/options - ERROR=0 - break - fi - checkopt_toolkit_motif - if [ $? -eq 0 ]; then - echo " toolkit: motif" >> $TEMP_DIR/options - ERROR=0 - break - fi - break - done - if [ $ERROR -ne 0 ]; then - SAVED_ERROR=1 - fi - ERROR=$SAVED_ERROR - DEPENDENCIES_FAILED=$SAVED_DEPENDENCIES_FAILED= +if [ -z "$OPT_TOOLKIT" ]; then + echo "auto-detecting option 'toolkit'" + SAVED_ERROR="$ERROR" + SAVED_DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED" + ERROR=1 + while true + do + if isplatform "windows"; then + if checkopt_toolkit_winui ; then + echo " toolkit: winui" >> "$TEMP_DIR/options" + ERROR=0 + break + fi + fi + if isplatform "macos"; then + if checkopt_toolkit_cocoa ; then + echo " toolkit: cocoa" >> "$TEMP_DIR/options" + ERROR=0 + break + fi + fi + if checkopt_toolkit_gtk4 ; then + echo " toolkit: gtk4" >> "$TEMP_DIR/options" + ERROR=0 + break + fi + if checkopt_toolkit_gtk3 ; then + echo " toolkit: gtk3" >> "$TEMP_DIR/options" + ERROR=0 + break + fi + if checkopt_toolkit_gtk2 ; then + echo " toolkit: gtk2" >> "$TEMP_DIR/options" + ERROR=0 + break + fi + if checkopt_toolkit_qt4 ; then + echo " toolkit: qt4" >> "$TEMP_DIR/options" + ERROR=0 + break + fi + if checkopt_toolkit_motif ; then + echo " toolkit: motif" >> "$TEMP_DIR/options" + ERROR=0 + break + fi + break + done + if [ $ERROR -ne 0 ]; then + SAVED_ERROR=1 + SAVED_DEPENDENCIES_FAILED="option 'toolkit' $SAVED_DEPENDENCIES_FAILED" + fi + ERROR="$SAVED_ERROR" + DEPENDENCIES_FAILED="$SAVED_DEPENDENCIES_FAILED" else - if false; then - false - elif [ $OPT_TOOLKIT = "gtk3" ]; then - echo " toolkit: $OPT_TOOLKIT" >> $TEMP_DIR/options - checkopt_toolkit_gtk3 - if [ $? -ne 0 ]; then - ERROR=1 - fi - elif [ $OPT_TOOLKIT = "gtk2" ]; then - echo " toolkit: $OPT_TOOLKIT" >> $TEMP_DIR/options - checkopt_toolkit_gtk2 - if [ $? -ne 0 ]; then - ERROR=1 - fi - elif [ $OPT_TOOLKIT = "gtk2legacy" ]; then - echo " toolkit: $OPT_TOOLKIT" >> $TEMP_DIR/options - checkopt_toolkit_gtk2legacy - if [ $? -ne 0 ]; then - ERROR=1 - fi - elif [ $OPT_TOOLKIT = "qt5" ]; then - echo " toolkit: $OPT_TOOLKIT" >> $TEMP_DIR/options - checkopt_toolkit_qt5 - if [ $? -ne 0 ]; then - ERROR=1 - fi - elif [ $OPT_TOOLKIT = "qt4" ]; then - echo " toolkit: $OPT_TOOLKIT" >> $TEMP_DIR/options - checkopt_toolkit_qt4 - if [ $? -ne 0 ]; then - ERROR=1 - fi - elif [ $OPT_TOOLKIT = "motif" ]; then - echo " toolkit: $OPT_TOOLKIT" >> $TEMP_DIR/options - checkopt_toolkit_motif - if [ $? -ne 0 ]; then - ERROR=1 - fi - fi + echo "checking option toolkit = $OPT_TOOLKIT" + if false; then + false + elif [ "$OPT_TOOLKIT" = "libadwaita" ]; then + echo " toolkit: $OPT_TOOLKIT" >> $TEMP_DIR/options + if checkopt_toolkit_libadwaita ; then + : + else + ERROR=1 + DEPENDENCIES_FAILED="option 'toolkit' $DEPENDENCIES_FAILED" + fi + elif [ "$OPT_TOOLKIT" = "gtk4" ]; then + echo " toolkit: $OPT_TOOLKIT" >> $TEMP_DIR/options + if checkopt_toolkit_gtk4 ; then + : + else + ERROR=1 + DEPENDENCIES_FAILED="option 'toolkit' $DEPENDENCIES_FAILED" + fi + elif [ "$OPT_TOOLKIT" = "gtk3" ]; then + echo " toolkit: $OPT_TOOLKIT" >> $TEMP_DIR/options + if checkopt_toolkit_gtk3 ; then + : + else + ERROR=1 + DEPENDENCIES_FAILED="option 'toolkit' $DEPENDENCIES_FAILED" + fi + elif [ "$OPT_TOOLKIT" = "gtk2" ]; then + echo " toolkit: $OPT_TOOLKIT" >> $TEMP_DIR/options + if checkopt_toolkit_gtk2 ; then + : + else + ERROR=1 + DEPENDENCIES_FAILED="option 'toolkit' $DEPENDENCIES_FAILED" + fi + elif [ "$OPT_TOOLKIT" = "gtk2legacy" ]; then + echo " toolkit: $OPT_TOOLKIT" >> $TEMP_DIR/options + if checkopt_toolkit_gtk2legacy ; then + : + else + ERROR=1 + DEPENDENCIES_FAILED="option 'toolkit' $DEPENDENCIES_FAILED" + fi + elif [ "$OPT_TOOLKIT" = "qt5" ]; then + echo " toolkit: $OPT_TOOLKIT" >> $TEMP_DIR/options + if checkopt_toolkit_qt5 ; then + : + else + ERROR=1 + DEPENDENCIES_FAILED="option 'toolkit' $DEPENDENCIES_FAILED" + fi + elif [ "$OPT_TOOLKIT" = "qt4" ]; then + echo " toolkit: $OPT_TOOLKIT" >> $TEMP_DIR/options + if checkopt_toolkit_qt4 ; then + : + else + ERROR=1 + DEPENDENCIES_FAILED="option 'toolkit' $DEPENDENCIES_FAILED" + fi + elif [ "$OPT_TOOLKIT" = "cocoa" ]; then + echo " toolkit: $OPT_TOOLKIT" >> $TEMP_DIR/options + if checkopt_toolkit_cocoa ; then + : + else + ERROR=1 + DEPENDENCIES_FAILED="option 'toolkit' $DEPENDENCIES_FAILED" + fi + elif [ "$OPT_TOOLKIT" = "motif" ]; then + echo " toolkit: $OPT_TOOLKIT" >> $TEMP_DIR/options + if checkopt_toolkit_motif ; then + : + else + ERROR=1 + DEPENDENCIES_FAILED="option 'toolkit' $DEPENDENCIES_FAILED" + fi + fi fi -echo >> $TEMP_DIR/config.mk -if [ ! -z "${CFLAGS}" ]; then - echo "TK_CFLAGS += $CFLAGS" >> $TEMP_DIR/config.mk +if [ -n "${TEMP_CFLAGS}" ] && [ -n "$lang_c" ]; then + echo "TK_CFLAGS += $TEMP_CFLAGS" >> "$TEMP_DIR/flags.mk" +fi +if [ -n "${TEMP_CXXFLAGS}" ] && [ -n "$lang_cpp" ]; then + echo "TK_CXXFLAGS += $TEMP_CXXFLAGS" >> "$TEMP_DIR/flags.mk" fi -if [ ! -z "${CXXFLAGS}" ]; then - echo "TK_CXXFLAGS += $CXXFLAGS" >> $TEMP_DIR/config.mk +if [ "$BUILD_TYPE" = "debug" ]; then + if [ -n "$lang_c" ]; then + echo 'TK_CFLAGS += ${DEBUG_CC_FLAGS}' >> "$TEMP_DIR/flags.mk" + fi + if [ -n "$lang_cpp" ]; then + echo 'TK_CXXFLAGS += ${DEBUG_CXX_FLAGS}' >> "$TEMP_DIR/flags.mk" + fi fi -if [ ! -z "${LDFLAGS}" ]; then - echo "TK_LDFLAGS += $LDFLAGS" >> $TEMP_DIR/config.mk +if [ "$BUILD_TYPE" = "release" ]; then + if [ -n "$lang_c" ]; then + echo 'TK_CFLAGS += ${RELEASE_CC_FLAGS}' >> "$TEMP_DIR/flags.mk" + fi + if [ -n "$lang_cpp" ]; then + echo 'TK_CXXFLAGS += ${RELEASE_CXX_FLAGS}' >> "$TEMP_DIR/flags.mk" + fi +fi +if [ -n "${TEMP_LDFLAGS}" ]; then + echo "TK_LDFLAGS += $TEMP_LDFLAGS" >> "$TEMP_DIR/flags.mk" fi + +# final result if [ $ERROR -ne 0 ]; then - echo - echo "Error: Unresolved dependencies" - echo $DEPENDENCIES_FAILED - rm -Rf $TEMP_DIR - exit 1 + echo + echo "Error: Unresolved dependencies" + echo "$DEPENDENCIES_FAILED" + abort_configure fi echo "configure finished" echo echo "Build Config:" -echo " PREFIX: $PREFIX" -echo " TOOLCHAIN: $TOOLCHAIN_NAME" +echo " PREFIX: $prefix" +echo " TOOLCHAIN: $TOOLCHAIN_NAME" echo "Options:" -cat $TEMP_DIR/options +cat "$TEMP_DIR/options" echo -cat $TEMP_DIR/config.mk $TEMP_DIR/make.mk > config.mk -rm -Rf $TEMP_DIR +# generate the config.mk file +cat > "$TEMP_DIR/config.mk" << __EOF__ +# +# config.mk generated by configure +# +__EOF__ +write_toolchain_defaults "$TEMP_DIR/toolchain.mk" +cat "$TEMP_DIR/vars.mk" "$TEMP_DIR/toolchain.mk" "$TEMP_DIR/flags.mk" "$TEMP_DIR/make.mk" > config.mk +rm -Rf "$TEMP_DIR" diff -r fe49cff3c571 -r bb7da585debc make/Makefile.mk --- a/make/Makefile.mk Sun May 23 09:44:43 2021 +0200 +++ b/make/Makefile.mk Sat Jan 04 16:38:48 2025 +0100 @@ -1,7 +1,7 @@ # # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. # -# Copyright 2013 Olaf Wintermann. All rights reserved. +# Copyright 2023 Olaf Wintermann. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: @@ -32,7 +32,7 @@ include config.mk BUILD_DIRS = build/bin build/lib -BUILD_DIRS += build/application +BUILD_DIRS += build/application build/ucx BUILD_DIRS += build/ui/common build/ui/$(TOOLKIT) all: $(BUILD_DIRS) ucx ui application @@ -41,11 +41,11 @@ $(BUILD_DIRS): mkdir -p $@ -ucx: FORCE - cd ucx; $(MAKE) +ui: ucx FORCE + cd ui; $(MAKE) all -ui: FORCE - cd ui; $(MAKE) all +ucx: FORCE + cd ucx; $(MAKE) all application: ui FORCE cd application; $(MAKE) diff -r fe49cff3c571 -r bb7da585debc make/cc.mk --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/make/cc.mk Sat Jan 04 16:38:48 2025 +0100 @@ -0,0 +1,14 @@ +# +# cc toolchain config +# + +CFLAGS = +CXXFLAGS = +DEBUG_CC_FLAGS = -g +DEBUG_CXX_FLAGS = -g +RELEASE_CC_FLAGS = -O3 -DNDEBUG +RELEASE_CXX_FLAGS = -O3 -DNDEBUG +LDFLAGS = + +SHLIB_CFLAGS = -fPIC +SHLIB_LDFLAGS = -shared \ No newline at end of file diff -r fe49cff3c571 -r bb7da585debc make/clang.mk --- a/make/clang.mk Sun May 23 09:44:43 2021 +0200 +++ b/make/clang.mk Sat Jan 04 16:38:48 2025 +0100 @@ -2,8 +2,13 @@ # clang toolchain config # -CFLAGS = -LDFLAGS = +CFLAGS = +CXXFLAGS = +DEBUG_CC_FLAGS = -g +DEBUG_CXX_FLAGS = -g +RELEASE_CC_FLAGS = -O3 -DNDEBUG +RELEASE_CXX_FLAGS = -O3 -DNDEBUG +LDFLAGS = SHLIB_CFLAGS = -fPIC SHLIB_LDFLAGS = -shared diff -r fe49cff3c571 -r bb7da585debc make/configure.vm --- a/make/configure.vm Sun May 23 09:44:43 2021 +0200 +++ b/make/configure.vm Sat Jan 04 16:38:48 2025 +0100 @@ -1,78 +1,65 @@ #!/bin/sh +# create temporary directory +TEMP_DIR=".tmp-`uname -n`" +rm -Rf "$TEMP_DIR" +if mkdir -p "$TEMP_DIR"; then + : +else + echo "Cannot create tmp dir $TEMP_DIR" + echo "Abort" + exit 1 +fi +touch "$TEMP_DIR/options" +touch "$TEMP_DIR/features" + +# define standard variables +# also define standard prefix (this is where we will search for config.site) +prefix=/usr +exec_prefix= +bindir= +sbindir= +libdir= +libexecdir= +datarootdir= +datadir= +sysconfdir= +sharedstatedir= +localstatedir= +runstatedir= +includedir= +infodir= +localedir= +mandir= + +# custom variables #foreach( $var in $vars ) #if( $var.exec ) -${var.name}=`${var.value}` +${var.varName}=`${var.value}` #else -${var.name}=${var.value} +${var.varName}="${var.value}" #end #end -#if ( ! $project.hasVar("PREFIX") ) -PREFIX=/usr +# features +#foreach( $feature in $features ) +#if( ${feature.auto} ) +${feature.varName}=auto #end -#if ( ! $project.hasVar("EPREFIX") ) -EPREFIX=$PREFIX #end -#if ( ! $project.hasVar("BINDIR") ) -BINDIR= -#end -#if ( ! $project.hasVar("SBINDIR") ) -SBINDIR= -#end -#if ( ! $project.hasVar("LIBDIR") ) -LIBDIR= -#end -#if ( ! $project.hasVar("LIBEXECDIR") ) -LIBEXECDIR= -#end -#if ( ! $project.hasVar("DATADIR") ) -DATADIR= -#end -#if ( ! $project.hasVar("SYSCONFDIR") ) -SYSCONFDIR= -#end -#if ( ! $project.hasVar("SHAREDSTATEDIR") ) -SHAREDSTATEDIR= -#end -#if ( ! $project.hasVar("LOCALSTATEDIR") ) -LOCALSTATEDIR= -#end -#if ( ! $project.hasVar("INCLUDEDIR") ) -INCLUDEDIR= -#end -#if ( ! $project.hasVar("INFODIR") ) -INFODIR= -#end -#if ( ! $project.hasVar("MANDIR") ) -MANDIR= -#end - -OS=`uname -s` -OS_VERSION=`uname -r` - -TEMP_DIR=".tmp-`uname -n`" -mkdir -p $TEMP_DIR -if [ $? -ne 0 ]; then - echo "Cannot create tmp dir" - echo "Abort" -fi -touch $TEMP_DIR/options -touch $TEMP_DIR/features - -# features -#foreach( $feature in $features ) -#if( ${feature.isDefault()} ) -${feature.getVarName()}=on -#end -#end +# clean abort +abort_configure() +{ + rm -Rf "$TEMP_DIR" + exit 1 +} # help text printhelp() { - echo "Usage: $0 [OPTIONS]..." - cat << __EOF__ + echo "Usage: $0 [OPTIONS]..." + cat << __EOF__ Installation directories: --prefix=PREFIX path prefix for architecture-independent files [/usr] @@ -85,28 +72,28 @@ --sysconfdir=DIR system configuration files [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --runstatedir=DIR run-time variable data [LOCALSTATEDIR/run] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] --datadir=DIR read-only architecture-independent data [DATAROOTDIR] --infodir=DIR info documentation [DATAROOTDIR/info] --mandir=DIR man documentation [DATAROOTDIR/man] + --localedir=DIR locale-dependent data [DATAROOTDIR/locale] #if( $options.size() > 0 ) Options: + --debug add extra compile flags for debug builds + --release add extra compile flags for release builds #foreach( $opt in $options ) - --${opt.getArgument()}=${opt.getValuesString()} + --${opt.argument}=${opt.valuesString} #end #end #if( $features.size() > 0 ) Optional Features: #foreach( $feature in $features ) -#if( $feature.default ) - --disable-${feature.arg} -#else - --enable-${feature.arg} -#end +${feature.helpText} #end #end @@ -114,297 +101,328 @@ } # -# parse arguments +# parse arguments # +BUILD_TYPE="default" #set( $D = '$' ) -for ARG in $@ +for ARG in "$@" do case "$ARG" in - "--prefix="*) PREFIX=${D}{ARG#--prefix=} ;; - "--exec-prefix="*) EPREFIX=${D}{ARG#--exec-prefix=} ;; - "--bindir="*) BINDIR=${D}{ARG#----bindir=} ;; - "--sbindir="*) SBINDIR=${D}{ARG#--sbindir=} ;; - "--libdir="*) LIBDIR=${D}{ARG#--libdir=} ;; - "--libexecdir="*) LIBEXECDIR=${D}{ARG#--libexecdir=} ;; - "--datadir="*) DATADIR=${D}{ARG#--datadir=} ;; - "--sysconfdir="*) SYSCONFDIR=${D}{ARG#--sysconfdir=} ;; - "--sharedstatedir="*) SHAREDSTATEDIR=${D}{ARG#--sharedstatedir=} ;; - "--localstatedir="*) LOCALSTATEDIR=${D}{ARG#--localstatedir=} ;; - "--includedir="*) INCLUDEDIR=${D}{ARG#--includedir=} ;; - "--infodir="*) INFODIR=${D}{ARG#--infodir=} ;; - "--mandir"*) MANDIR=${D}{ARG#--mandir} ;; - "--help"*) printhelp; exit 1 ;; - #foreach( $opt in $options ) - "--${opt.getArgument()}="*) ${opt.getVarName()}=${D}{ARG#--${opt.getArgument()}=} ;; + "--prefix="*) prefix=${D}{ARG#--prefix=} ;; + "--exec-prefix="*) exec_prefix=${D}{ARG#--exec-prefix=} ;; + "--bindir="*) bindir=${D}{ARG#----bindir=} ;; + "--sbindir="*) sbindir=${D}{ARG#--sbindir=} ;; + "--libdir="*) libdir=${D}{ARG#--libdir=} ;; + "--libexecdir="*) libexecdir=${D}{ARG#--libexecdir=} ;; + "--datarootdir="*) datarootdir=${D}{ARG#--datarootdir=} ;; + "--datadir="*) datadir=${D}{ARG#--datadir=} ;; + "--sysconfdir="*) sysconfdir=${D}{ARG#--sysconfdir=} ;; + "--sharedstatedir="*) sharedstatedir=${D}{ARG#--sharedstatedir=} ;; + "--localstatedir="*) localstatedir=${D}{ARG#--localstatedir=} ;; + "--includedir="*) includedir=${D}{ARG#--includedir=} ;; + "--infodir="*) infodir=${D}{ARG#--infodir=} ;; + "--mandir"*) mandir=${D}{ARG#--mandir} ;; + "--localedir"*) localedir=${D}{ARG#--localedir} ;; + "--help"*) printhelp; abort_configure ;; + "--debug") BUILD_TYPE="debug" ;; + "--release") BUILD_TYPE="release" ;; + #foreach( $opt in $options ) + "--${opt.argument}="*) ${opt.varName}=${D}{ARG#--${opt.argument}=} ;; #end - #foreach( $feature in $features ) - "--enable-${feature.arg}") ${feature.getVarName()}=on ;; - "--disable-${feature.arg}") unset ${feature.getVarName()} ;; - #end - "-"*) echo "unknown option: $ARG"; exit 1 ;; - esac + #foreach( $feature in $features ) + "--enable-${feature.arg}") ${feature.varName}=on ;; + "--disable-${feature.arg}") unset ${feature.varName} ;; + #end + "-"*) echo "unknown option: $ARG"; abort_configure ;; + esac done -# set dir variables -if [ -z "$BINDIR" ]; then - BINDIR=$EPREFIX/bin -fi -if [ -z "$SBINDIR" ]; then - SBINDIR=$EPREFIX/sbin -fi -if [ -z "$LIBDIR" ]; then - LIBDIR=$EPREFIX/lib -fi -if [ -z "$LIBEXEC" ]; then - LIBEXECDIR=$EPREFIX/libexec -fi -if [ -z "$DATADIR" ]; then - DATADIR=$PREFIX/share -fi -if [ -z "$SYSCONFDIR" ]; then - SYSCONFDIR=$PREFIX/etc -fi -if [ -z "$SHAREDSTATEDIR" ]; then - SHAREDSTATEDIR=$PREFIX/com -fi -if [ -z "$LOCALSTATEDIR" ]; then - LOCALSTATEDIR=$PREFIX/var -fi -if [ -z "$INCLUDEDIR" ]; then - INCLUDEDIR=$PREFIX/include -fi -if [ -z "$INFODIR" ]; then - INFODIR=$PREFIX/info -fi -if [ -z "$MANDIR" ]; then - MANDIR=$PREFIX/man +## Begin unparsed content. ** +#[[ + +# set defaults for dir variables +: ${exec_prefix:="$prefix"} +: ${bindir:='${exec_prefix}/bin'} +: ${sbindir:='${exec_prefix}/sbin'} +: ${libdir:='${exec_prefix}/lib'} +: ${libexecdir:='${exec_prefix}/libexec'} +: ${datarootdir:='${prefix}/share'} +: ${datadir:='${datarootdir}'} +: ${sysconfdir:='${prefix}/etc'} +: ${sharedstatedir:='${prefix}/com'} +: ${localstatedir:='${prefix}/var'} +: ${runstatedir:='${localstatedir}/run'} +: ${includedir:='${prefix}/include'} +: ${infodir:='${datarootdir}/info'} +: ${mandir:='${datarootdir}/man'} +: ${localedir:='${datarootdir}/locale'} + +# check if a config.site exists and load it +if [ -n "$CONFIG_SITE" ]; then + # CONFIG_SITE may contain space separated file names + for cs in $CONFIG_SITE; do + printf "loading defaults from $cs... " + . "$cs" + echo ok + done +elif [ -f "$prefix/share/config.site" ]; then + printf "loading site defaults... " + . "$prefix/share/config.site" + echo ok +elif [ -f "$prefix/etc/config.site" ]; then + printf "loading site defaults... " + . "$prefix/etc/config.site" + echo ok fi -which pkg-config > /dev/null -if [ $? -eq 0 ]; then - PKG_CONFIG=pkg-config -else - PKG_CONFIG=false -fi +# Test for availability of pkg-config +PKG_CONFIG=`command -v pkg-config` +: ${PKG_CONFIG:="false"} # Simple uname based platform detection # $PLATFORM is used for platform dependent dependency selection +OS=`uname -s` +OS_VERSION=`uname -r` printf "detect platform... " -if [ $OS = SunOS ]; then +if [ "$OS" = "SunOS" ]; then PLATFORM="solaris sunos unix svr4" -fi -if [ $OS = Linux ]; then +elif [ "$OS" = "Linux" ]; then PLATFORM="linux unix" -fi -if [ $OS = FreeBSD ]; then +elif [ "$OS" = "FreeBSD" ]; then PLATFORM="freebsd bsd unix" -fi -if [ $OS = Darwin ]; then +elif [ "$OS" = "OpenBSD" ]; then + PLATFORM="openbsd bsd unix" +elif [ "$OS" = "NetBSD" ]; then + PLATFORM="netbsd bsd unix" +elif [ "$OS" = "Darwin" ]; then PLATFORM="macos osx bsd unix" -fi -echo $OS | grep "MINGW" > /dev/null -if [ $? -eq 0 ]; then +elif echo "$OS" | grep -i "MINGW" > /dev/null; then PLATFORM="windows mingw" fi - -if [ -z "$PLATFORM" ]; then - PLATFORM="unix" -fi +: ${PLATFORM:="unix"} -for p in $PLATFORM -do - PLATFORM_NAME=$p - break -done -echo $PLATFORM_NAME +PLATFORM_NAME=`echo "$PLATFORM" | cut -f1 -d' ' -` +echo "$PLATFORM_NAME" isplatform() { for p in $PLATFORM do - if [ $p = $1 ]; then + if [ "$p" = "$1" ]; then return 0 fi done return 1 } -isnotplatform() +notisplatform() { for p in $PLATFORM do - if [ $p = $1 ]; then + if [ "$p" = "$1" ]; then + return 1 + fi + done + return 0 +} +istoolchain() +{ + for t in $TOOLCHAIN + do + if [ "$t" = "$1" ]; then + return 0 + fi + done + return 1 +} +notistoolchain() +{ + for t in $TOOLCHAIN + do + if [ "$t" = "$1" ]; then return 1 fi done return 0 } - -# generate config.mk and config.h -cat > $TEMP_DIR/config.mk << __EOF__ -# -# config.mk generated by configure -# - -# general vars -#foreach( $var in $vars ) -${var.name}=$${var.name} -#end +]]# +## End of unparsed content ** -#if ( ! $project.hasVar("PREFIX") ) -PREFIX=$PREFIX -#end -#if ( ! $project.hasVar("EPREFIX") ) -EPREFIX=$EPREFIX -#end - -#if ( ! $project.hasVar("BINDIR") ) -BINDIR=$BINDIR -#end -#if ( ! $project.hasVar("SBINDIR") ) -SBINDIR=$SBINDIR +# generate vars.mk +cat > "$TEMP_DIR/vars.mk" << __EOF__ +prefix=$prefix +exec_prefix=$exec_prefix +bindir=$bindir +sbindir=$sbindir +libdir=$libdir +libexecdir=$libexecdir +datarootdir=$datarootdir +datadir=$datadir +sysconfdir=$sysconfdir +sharedstatedir=$sharedstatedir +localstatedir=$localstatedir +runstatedir=$runstatedir +includedir=$includedir +infodir=$infodir +mandir=$mandir +localedir=$localedir +#foreach( $var in $vars ) +${var.varName}=${D}${var.varName} #end -#if ( ! $project.hasVar("LIBDIR") ) -LIBDIR=$LIBDIR -#end -#if ( ! $project.hasVar("LIBEXECDIR") ) -LIBEXECDIR=$LIBEXECDIR -#end -#if ( ! $project.hasVar("DATADIR") ) -DATADIR=$DATADIR -#end -#if ( ! $project.hasVar("SYSCONFDIR") ) -SYSCONFDIR=$SYSCONFDIR -#end -#if ( ! $project.hasVar("SHAREDSTATEDIR") ) -SHAREDSTATEDIR=$SHAREDSTATEDIR -#end -#if ( ! $project.hasVar("LOCALSTATEDIR") ) -LOCALSTATEDIR=$LOCALSTATEDIR -#end -#if ( ! $project.hasVar("INCLUDEDIR") ) -INCLUDEDIR=$INCLUDEDIR -#end -#if ( ! $project.hasVar("INFODIR") ) -INFODIR=$INFODIR -#end -#if ( ! $project.hasVar("MANDIR") ) -MANDIR=$MANDIR -#end - __EOF__ -echo > $TEMP_DIR/make.mk - -ENV_CFLAGS=$CFLAGS -ENV_LDFLAGS=$LDFLAGS -ENV_CXXFLAGS=$CXXFLAGS - -# Toolchain detection -# this will insert make vars to config.mk +# toolchain detection utilities . make/toolchain.sh -# add user specified flags to config.mk -echo >> $TEMP_DIR/config.mk -if [ ! -z "${ENV_CFLAGS}" ]; then - echo "CFLAGS += $ENV_CFLAGS" >> $TEMP_DIR/config.mk -fi -if [ ! -z "${ENV_CXXFLAGS}" ]; then - echo "CXXFLAGS += $ENV_CXXFLAGS" >> $TEMP_DIR/config.mk -fi -if [ ! -z "${ENV_LDFLAGS}" ]; then - echo "LDFLAGS += $ENV_LDFLAGS" >> $TEMP_DIR/config.mk -fi - # # DEPENDENCIES # -#foreach( $dependency in $namedDependencies ) -dependency_${dependency.name}() +# check languages +lang_c= +lang_cpp= +#foreach( $lang in $languages ) +if detect_${lang}_compiler ; then + lang_${lang}=1 +fi +#end + +# create buffer for make variables required by dependencies +echo > "$TEMP_DIR/make.mk" + +test_pkg_config() { - printf "checking for ${dependency.name}... " - #foreach( $sub in $dependency.getSubdependencies() ) - # dependency $sub.name $sub.getPlatformString() + if "$PKG_CONFIG" --exists "$1" ; then : + else return 1 ; fi + if [ -z "$2" ] || "$PKG_CONFIG" --atleast-version="$2" "$1" ; then : + else return 1 ; fi + if [ -z "$3" ] || "$PKG_CONFIG" --exact-version="$3" "$1" ; then : + else return 1 ; fi + if [ -z "$4" ] || "$PKG_CONFIG" --max-version="$4" "$1" ; then : + else return 1 ; fi + return 0 +} + +print_check_msg() +{ + if [ -z "$1" ]; then + shift + printf "$@" + fi +} + +#foreach( $dependency in $namedDependencies ) +dependency_error_${dependency.id}() +{ + print_check_msg "${D}dep_checked_${dependency.id}" "checking for ${dependency.name}... " + #foreach( $sub in $dependency.subdependencies ) + # dependency $sub.fullName while true do - #if( $sub.platform ) - if isnotplatform "${sub.platform}"; then + #if( $sub.platform ) + if notisplatform "${sub.platform}"; then + break + fi + #end + #if( $sub.toolchain ) + if notistoolchain "${sub.toolchain}"; then + break + fi + #end + #foreach( $np in $sub.notList ) + if isplatform "${np}" || istoolchain "${np}"; then break fi - #end - #foreach( $not in $sub.getNotList() ) - if isplatform "${not}"; then + #end + #foreach( $lang in $sub.lang ) + if [ -z "$lang_${lang}" ] ; then break fi - #end + #end #if( $sub.pkgconfig.size() > 0 ) if [ -z "$PKG_CONFIG" ]; then - break + break + fi + #end + #foreach( $test in $sub.tests ) + if $test > /dev/null ; then + : + else + break fi #end #foreach( $pkg in $sub.pkgconfig ) - $PKG_CONFIG $pkg.getPkgConfigParam() - if [ $? -ne 0 ] ; then + if test_pkg_config "$pkg.name" "$pkg.atleast" "$pkg.exact" "$pkg.max" ; then + TEMP_CFLAGS="$TEMP_CFLAGS `"$PKG_CONFIG" --cflags $pkg.name`" + TEMP_LDFLAGS="$TEMP_LDFLAGS `"$PKG_CONFIG" --libs $pkg.name`" + else break fi - CFLAGS="$CFLAGS `$PKG_CONFIG --cflags $pkg.getPkgConfigParam()`" - LDFLAGS="$LDFLAGS `$PKG_CONFIG --libs $pkg.getPkgConfigParam()`" #end #foreach( $flags in $sub.flags ) #if( $flags.exec ) - $flags.value > /dev/null - if [ $? -eq 0 ]; then - $flags.varName="$$flags.varName `$flags.value`" + if tmp_flags=`$flags.value` ; then + TEMP_$flags.varName="$TEMP_$flags.varName $tmp_flags" else break fi #else - $flags.varName="$$flags.varName $flags.value" + TEMP_$flags.varName="$TEMP_$flags.varName $flags.value" #end #end - #foreach( $test in $sub.tests ) - $test > /dev/null - if [ $? -ne 0 ]; then - break - fi - #end - #if ( $sub.make.length() > 0 ) - cat >> $TEMP_DIR/make.mk << __EOF__ -# Dependency: $dependency.name + #if ( $sub.make.length() > 0 ) + cat >> $TEMP_DIR/make.mk << __EOF__ +# Dependency: $dependency.name $sub.make __EOF__ #end - echo yes - return 0 + print_check_msg "${D}dep_checked_${dependency.id}" "yes\n" + dep_checked_${dependency.id}=1 + return 1 done - - #end - echo no - return 1 + + #end + print_check_msg "${D}dep_checked_${dependency.id}" "no\n" + dep_checked_${dependency.id}=1 + return 0 } #end +# start collecting dependency information +echo > "$TEMP_DIR/flags.mk" + DEPENDENCIES_FAILED= ERROR=0 #if( $dependencies.size() > 0 ) -# general dependencies -CFLAGS= -LDFLAGS= +# unnamed dependencies +TEMP_CFLAGS= +TEMP_CXXFLAGS= +TEMP_LDFLAGS= #foreach( $dependency in $dependencies ) while true do - #if( $dependency.platform ) - if isnotplatform "${dependency.platform}"; then + #if( $dependency.platform ) + if notisplatform "${dependency.platform}"; then + break + fi + #end + #if( $dependency.toolchain ) + if notistoolchain "${dependency.toolchain}"; then break fi #end - #foreach( $not in $dependency.getNotList() ) - if isplatform "${not}"; then + #foreach( $np in $dependency.notList ) + if isplatform "${np}" || istoolchain "${np}"; then break fi - #end + #end while true do + #foreach( $lang in $dependency.lang ) + if [ -z "$lang_${lang}" ] ; then + ERROR=1 + break + fi + #end #if( $dependency.pkgconfig.size() > 0 ) if [ -z "$PKG_CONFIG" ]; then ERROR=1 @@ -412,54 +430,54 @@ fi #end #foreach( $pkg in $dependency.pkgconfig ) - printf "checking for pkg-config package $pkg.getPkgConfigParam()... " - $PKG_CONFIG $pkg.getPkgConfigParam() - if [ $? -ne 0 ]; then - echo no + print_check_msg "${D}dep_pkgconfig_checked_${pkg.id}" "checking for pkg-config package $pkg.name... " + if test_pkg_config "$pkg.name" "$pkg.atleast" "$pkg.exact" "$pkg.max" ; then + print_check_msg "${D}dep_pkgconfig_checked_${pkg.id}" "yes\n" + dep_pkgconfig_checked_${pkg.id}=1 + TEMP_CFLAGS="$TEMP_CFLAGS `"$PKG_CONFIG" --cflags $pkg.name`" + TEMP_LDFLAGS="$TEMP_LDFLAGS `"$PKG_CONFIG" --libs $pkg.name`" + else + print_check_msg "${D}dep_pkgconfig_checked_${pkg.id}" "no\n" + dep_pkgconfig_checked_${pkg.id}=1 ERROR=1 break fi - echo yes - CFLAGS="$CFLAGS `$PKG_CONFIG --cflags $pkg.getPkgConfigParam()`" - LDFLAGS="$LDFLAGS `$PKG_CONFIG --libs $pkg.getPkgConfigParam()`" #end - + #foreach( $flags in $dependency.flags ) #if( $flags.exec ) $flags.value > /dev/null - if [ $? -ne 0 ]; then - $flags.varName="$$flags.varName `$flags.value`" + if tmp_flags=`$flags.value` ; then + TEMP_$flags.varName="$TEMP_$flags.varName $tmp_flags" else ERROR=1 break fi #else - $flags.varName="$$flags.varName $flags.value" + TEMP_$flags.varName="$TEMP_$flags.varName $flags.value" #end #end - #if ( $dependency.make.length() > 0 ) - cat >> $TEMP_DIR/make.mk << __EOF__ + #if ( $dependency.make.length() > 0 ) + cat >> "$TEMP_DIR/make.mk" << __EOF__ $dependency.make __EOF__ #end - break done - break done #end -# add general dependency flags to config.mk -echo >> $TEMP_DIR/config.mk -if [ ! -z "${CFLAGS}" ]; then - echo "CFLAGS += $CFLAGS" >> $TEMP_DIR/config.mk +# add general dependency flags to flags.mk +echo "# general flags" >> "$TEMP_DIR/flags.mk" +if [ -n "${TEMP_CFLAGS}" ] && [ -n "$lang_c" ]; then + echo "CFLAGS += $TEMP_CFLAGS" >> "$TEMP_DIR/flags.mk" fi -if [ ! -z "${CXXFLAGS}" ]; then - echo "CXXFLAGS += $CXXFLAGS" >> $TEMP_DIR/config.mk +if [ -n "${TEMP_CXXFLAGS}" ] && [ -n "$lang_cpp" ]; then + echo "CXXFLAGS += $TEMP_CXXFLAGS" >> "$TEMP_DIR/flags.mk" fi -if [ ! -z "${LDFLAGS}" ]; then - echo "LDFLAGS += $LDFLAGS" >> $TEMP_DIR/config.mk +if [ -n "${TEMP_LDFLAGS}" ]; then + echo "LDFLAGS += $TEMP_LDFLAGS" >> "$TEMP_DIR/flags.mk" fi #end @@ -470,25 +488,25 @@ #foreach( $val in $opt.values ) ${val.func}() { - VERR=0 - #foreach( $dep in $val.dependencies ) - dependency_$dep - if [ $? -ne 0 ]; then - VERR=1 - fi - #end - if [ $VERR -ne 0 ]; then - return 1 - fi - #foreach( $def in $val.defines ) - CFLAGS="$CFLAGS ${def.toFlags()}" - #end - #if( $val.hasMake() ) - cat >> $TEMP_DIR/make.mk << __EOF__ + VERR=0 + #foreach( $dep in $val.dependencies ) + if dependency_error_$dep ; then + VERR=1 + fi + #end + if [ $VERR -ne 0 ]; then + return 1 + fi + #foreach( $def in $val.defines ) + TEMP_CFLAGS="$TEMP_CFLAGS ${def.toFlags()}" + TEMP_CXXFLAGS="$TEMP_CXXFLAGS ${def.toFlags()}" + #end + #if( $val.hasMake() ) + cat >> "$TEMP_DIR/make.mk" << __EOF__ $val.make __EOF__ - #end - return 0 + #end + return 0 } #end #end @@ -496,120 +514,160 @@ # # TARGETS # -CFLAGS= -CXXFLAGS= -LDFLAGS= #foreach( $target in $targets ) +echo >> "$TEMP_DIR/flags.mk" #if ( $target.name ) -# Target: $target.name +echo "configuring target: $target.name" +echo "# flags for target $target.name" >> "$TEMP_DIR/flags.mk" #else -# Target +echo "configuring global target" +echo "# flags for unnamed target" >> "$TEMP_DIR/flags.mk" #end -CFLAGS= -LDFLAGS= -CXXFLAGS= +TEMP_CFLAGS= +TEMP_CXXFLAGS= +TEMP_LDFLAGS= #foreach( $dependency in $target.dependencies ) -dependency_$dependency -if [ $? -ne 0 ]; then - DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED ${dependency} " - ERROR=1 +if dependency_error_$dependency; then + DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED ${dependency} " + ERROR=1 fi #end # Features #foreach( $feature in $target.features ) -if [ ! -z "$${feature.getVarName()}" ]; then +if [ -n "${D}${feature.varName}" ]; then #foreach( $dependency in $feature.dependencies ) - # check dependency - dependency_$dependency - if [ $? -ne 0 ]; then - # "auto" features can fail and are just disabled in this case - if [ $${feature.getVarName()} != "auto" ]; then - DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED ${dependency} " - ERROR=1 - fi - fi + # check dependency + if dependency_error_$dependency ; then + # "auto" features can fail and are just disabled in this case + if [ "${D}${feature.varName}" = "auto" ]; then + DISABLE_${feature.varName}=1 + else + DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED ${dependency} " + ERROR=1 + fi + fi #end + if [ -n "$DISABLE_${feature.varName}" ]; then + unset ${feature.varName} + fi fi #end #foreach( $opt in $target.options ) # Option: --${opt.argument} -if [ -z ${D}${opt.getVarName()} ]; then - SAVED_ERROR=$ERROR - SAVED_DEPENDENCIES_FAILED=$DEPENDENCIES_FAILED - ERROR=0 - while true - do - #foreach( $optdef in $opt.defaults ) - #if( $optdef.platform ) - if isplatform "$optdef.platform"; then - #end - $optdef.func - if [ $? -eq 0 ]; then - echo " ${opt.argument}: ${optdef.valueName}" >> $TEMP_DIR/options - ERROR=0 - break - fi - #if( $optdef.platform ) - fi - #end - #end - break - done - if [ $ERROR -ne 0 ]; then - SAVED_ERROR=1 - fi - ERROR=$SAVED_ERROR - DEPENDENCIES_FAILED=$SAVED_DEPENDENCIES_FAILED= +if [ -z "${D}${opt.varName}" ]; then + echo "auto-detecting option '${opt.argument}'" + SAVED_ERROR="$ERROR" + SAVED_DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED" + ERROR=1 + while true + do + #foreach( $optdef in $opt.defaults ) + #if( $optdef.platform ) + if isplatform "$optdef.platform"; then + #end + if $optdef.func ; then + echo " ${opt.argument}: ${optdef.valueName}" >> "$TEMP_DIR/options" + ERROR=0 + break + fi + #if( $optdef.platform ) + fi + #end + #end + break + done + if [ $ERROR -ne 0 ]; then + SAVED_ERROR=1 + SAVED_DEPENDENCIES_FAILED="option '${opt.argument}' $SAVED_DEPENDENCIES_FAILED" + fi + ERROR="$SAVED_ERROR" + DEPENDENCIES_FAILED="$SAVED_DEPENDENCIES_FAILED" else - if false; then - false - #foreach( $optval in $opt.values ) - elif [ ${D}${opt.getVarName()} = "${optval.value}" ]; then - echo " ${opt.argument}: ${D}${opt.getVarName()}" >> $TEMP_DIR/options - $optval.func - if [ $? -ne 0 ]; then - ERROR=1 - fi - #end - fi + echo "checking option ${opt.argument} = ${D}${opt.varName}" + if false; then + false + #foreach( $optval in $opt.values ) + elif [ "${D}${opt.varName}" = "${optval.value}" ]; then + echo " ${opt.argument}: ${D}${opt.varName}" >> $TEMP_DIR/options + if $optval.func ; then + : + else + ERROR=1 + DEPENDENCIES_FAILED="option '${opt.argument}' $DEPENDENCIES_FAILED" + fi + #end + fi fi #end -echo >> $TEMP_DIR/config.mk -if [ ! -z "${CFLAGS}" ]; then - echo "${target.getCFlags()} += $CFLAGS" >> $TEMP_DIR/config.mk +if [ -n "${TEMP_CFLAGS}" ] && [ -n "$lang_c" ]; then + echo "${target.cFlags} += $TEMP_CFLAGS" >> "$TEMP_DIR/flags.mk" +fi +if [ -n "${TEMP_CXXFLAGS}" ] && [ -n "$lang_cpp" ]; then + echo "${target.cxxFlags} += $TEMP_CXXFLAGS" >> "$TEMP_DIR/flags.mk" fi -if [ ! -z "${CXXFLAGS}" ]; then - echo "${target.getCXXFlags()} += $CXXFLAGS" >> $TEMP_DIR/config.mk +if [ "$BUILD_TYPE" = "debug" ]; then + if [ -n "$lang_c" ]; then + echo '${target.cFlags} += ${DEBUG_CC_FLAGS}' >> "$TEMP_DIR/flags.mk" + fi + if [ -n "$lang_cpp" ]; then + echo '${target.cxxFlags} += ${DEBUG_CXX_FLAGS}' >> "$TEMP_DIR/flags.mk" + fi fi -if [ ! -z "${LDFLAGS}" ]; then - echo "${target.getLDFlags()} += $LDFLAGS" >> $TEMP_DIR/config.mk +if [ "$BUILD_TYPE" = "release" ]; then + if [ -n "$lang_c" ]; then + echo '${target.cFlags} += ${RELEASE_CC_FLAGS}' >> "$TEMP_DIR/flags.mk" + fi + if [ -n "$lang_cpp" ]; then + echo '${target.cxxFlags} += ${RELEASE_CXX_FLAGS}' >> "$TEMP_DIR/flags.mk" + fi +fi +if [ -n "${TEMP_LDFLAGS}" ]; then + echo "${target.ldFlags} += $TEMP_LDFLAGS" >> "$TEMP_DIR/flags.mk" fi #end + +# final result if [ $ERROR -ne 0 ]; then - echo - echo "Error: Unresolved dependencies" - echo $DEPENDENCIES_FAILED - rm -Rf $TEMP_DIR - exit 1 + echo + echo "Error: Unresolved dependencies" + echo "$DEPENDENCIES_FAILED" + abort_configure fi echo "configure finished" echo echo "Build Config:" -echo " PREFIX: $PREFIX" -echo " TOOLCHAIN: $TOOLCHAIN_NAME" +echo " PREFIX: $prefix" +echo " TOOLCHAIN: $TOOLCHAIN_NAME" #if ( $options.size() > 0 ) echo "Options:" -cat $TEMP_DIR/options +cat "$TEMP_DIR/options" +#end +#if ( $features.size() > 0 ) +echo "Features:" +#foreach( $feature in $features ) +if [ -n "${D}${feature.varName}" ]; then +echo " $feature.name: on" +else +echo " $feature.name: off" +fi +#end #end echo -cat $TEMP_DIR/config.mk $TEMP_DIR/make.mk > config.mk -rm -Rf $TEMP_DIR +# generate the config.mk file +cat > "$TEMP_DIR/config.mk" << __EOF__ +# +# config.mk generated by configure +# +__EOF__ +write_toolchain_defaults "$TEMP_DIR/toolchain.mk" +cat "$TEMP_DIR/vars.mk" "$TEMP_DIR/toolchain.mk" "$TEMP_DIR/flags.mk" "$TEMP_DIR/make.mk" > config.mk +rm -Rf "$TEMP_DIR" diff -r fe49cff3c571 -r bb7da585debc make/gcc.mk --- a/make/gcc.mk Sun May 23 09:44:43 2021 +0200 +++ b/make/gcc.mk Sat Jan 04 16:38:48 2025 +0100 @@ -2,8 +2,13 @@ # gcc toolchain config # -CFLAGS = -LDFLAGS = +CFLAGS = +CXXFLAGS = +DEBUG_CC_FLAGS = -g +DEBUG_CXX_FLAGS = -g +RELEASE_CC_FLAGS = -O3 -DNDEBUG +RELEASE_CXX_FLAGS = -O3 -DNDEBUG +LDFLAGS = SHLIB_CFLAGS = -fPIC SHLIB_LDFLAGS = -shared diff -r fe49cff3c571 -r bb7da585debc make/project.xml --- a/make/project.xml Sun May 23 09:44:43 2021 +0200 +++ b/make/project.xml Sat Jan 04 16:38:48 2025 +0100 @@ -1,12 +1,19 @@ - - + + gtk4 + -DUI_GTK4 + -lpthread + gtk+-3.0 -DUI_GTK3 @@ -23,50 +30,66 @@ -DUI_GTK2 -DUI_GTK2LEGACY -lpthread - - -DUI_WPF + + -DUI_WINUI + -DUI_COCOA -lobjc -framework Cocoa + + + -DUI_MOTIF -I/usr/local/include/X11 + -lXm -lXt -lX11 -lpthread + + -DUI_MOTIF -lXm -lXt -lX11 -lpthread - OBJ_EXT = o - LIB_EXT = a + OBJ_EXT = .o + LIB_EXT = .a PACKAGE_SCRIPT = package_osx.sh - OBJ_EXT = o - LIB_EXT = a + OBJ_EXT = .o + LIB_EXT = .a PACKAGE_SCRIPT = package_unix.sh + + -I/usr/local/include + -L/usr/local/lib + +