MacOS: create a bundled version of all example programs with fltk-config --post

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@9736 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Manolo Gouy 2012-12-05 14:53:03 +00:00
parent 4b6613cbd2
commit 598e2cb63b
5 changed files with 48 additions and 7 deletions

View File

@ -139,6 +139,7 @@ UNINSTALL_DESKTOP = @UNINSTALL_DESKTOP@
.o$(EXEEXT):
echo Linking $@...
$(CXX) $(ARCHFLAGS) $(LDFLAGS) $< $(LINKFLTK) $(LDLIBS) -o $@
$(OSX_ONLY) ../fltk-config --post $@
.c.o:
echo Compiling $<...

View File

@ -183,6 +183,12 @@ include makedepend
clean:
$(RM) $(ALL) $(GLALL) core
for file in $(ALL) $(GLALL); do \
if [ $$file == "blocks" -o $$file == "checkers" -o $$file == "sudoku" ]; then \
continue; \
fi; \
$(OSX_ONLY) rm -f -r $$file.app; \
done
$(RM) *.o core.* *~ *.bck *.bak
$(RM) CubeViewUI.cxx CubeViewUI.h
$(RM) fast_slow.cxx fast_slow.h
@ -302,6 +308,7 @@ clock$(EXEEXT): clock.o
colbrowser$(EXEEXT): colbrowser.o
echo Linking $@...
$(CXX) $(ARCHFLAGS) $(LDFLAGS) -o $@ colbrowser.o $(LINKFLTKFORMS) $(LDLIBS)
$(OSX_ONLY) ../fltk-config --post $@
color_chooser$(EXEEXT): color_chooser.o
@ -316,12 +323,14 @@ demo$(EXEEXT): demo.o
device$(EXEEXT): device.o $(IMGLIBNAME)
echo Linking $@...
$(CXX) $(ARCHFLAGS) $(LDFLAGS) device.o -o $@ $(LINKFLTKIMG) $(LDLIBS)
$(OSX_ONLY) ../fltk-config --post $@
doublebuffer$(EXEEXT): doublebuffer.o
editor$(EXEEXT): editor.o
echo Linking $@...
$(CXX) $(ARCHFLAGS) $(LDFLAGS) editor.o -o $@ $(LINKFLTKIMG) $(LDLIBS)
$(OSX_ONLY) ../fltk-config --post $@
fast_slow$(EXEEXT): fast_slow.o
fast_slow.cxx: fast_slow.fl ../fluid/fluid$(EXEEXT)
@ -329,18 +338,21 @@ fast_slow.cxx: fast_slow.fl ../fluid/fluid$(EXEEXT)
file_chooser$(EXEEXT): file_chooser.o $(IMGLIBNAME)
echo Linking $@...
$(CXX) $(ARCHFLAGS) $(LDFLAGS) file_chooser.o -o $@ $(LINKFLTKIMG) $(LDLIBS)
$(OSX_ONLY) ../fltk-config --post $@
fonts$(EXEEXT): fonts.o
forms$(EXEEXT): forms.o
echo Linking $@...
$(CXX) $(ARCHFLAGS) $(LDFLAGS) -o $@ forms.o $(LINKFLTKFORMS) $(LDLIBS)
$(OSX_ONLY) ../fltk-config --post $@
hello$(EXEEXT): hello.o
help$(EXEEXT): help.o $(IMGLIBNAME)
echo Linking $@...
$(CXX) $(ARCHFLAGS) $(LDFLAGS) help.o -o $@ $(LINKFLTKIMG) $(LDLIBS)
$(OSX_ONLY) ../fltk-config --post $@
iconize$(EXEEXT): iconize.o
@ -356,12 +368,14 @@ input_choice$(EXEEXT): input_choice.o
keyboard$(EXEEXT): keyboard_ui.o keyboard.o
echo Linking $@...
$(CXX) $(ARCHFLAGS) $(LDFLAGS) -o $@ keyboard.o keyboard_ui.o $(LINKFLTK) $(LDLIBS)
$(OSX_ONLY) ../fltk-config --post $@
keyboard_ui.o: keyboard_ui.h
keyboard_ui.cxx: keyboard_ui.fl ../fluid/fluid$(EXEEXT)
label$(EXEEXT): label.o
echo Linking $@...
$(CXX) $(ARCHFLAGS) $(LDFLAGS) -o $@ label.o $(LINKFLTKFORMS) $(LDLIBS)
$(OSX_ONLY) ../fltk-config --post $@
line_style$(EXEEXT): line_style.o
@ -370,6 +384,7 @@ list_visuals$(EXEEXT): list_visuals.o
mandelbrot$(EXEEXT): mandelbrot_ui.o mandelbrot.o
echo Linking $@...
$(CXX) $(ARCHFLAGS) $(LDFLAGS) -o $@ mandelbrot.o mandelbrot_ui.o $(LINKFLTK) $(LDLIBS)
$(OSX_ONLY) ../fltk-config --post $@
mandelbrot_ui.o: mandelbrot_ui.h
mandelbrot_ui.cxx: mandelbrot_ui.fl ../fluid/fluid$(EXEEXT)
@ -382,12 +397,14 @@ minimum$(EXEEXT): minimum.o
native-filechooser$(EXEEXT): native-filechooser.o $(IMGLIBNAME)
echo Linking $@...
$(CXX) $(ARCHFLAGS) $(LDFLAGS) native-filechooser.o -o $@ $(LINKFLTKIMG) $(LDLIBS)
$(OSX_ONLY) ../fltk-config --post $@
navigation$(EXEEXT): navigation.o
output$(EXEEXT): output.o $(FLLIBNAME)
echo Linking $@...
$(CXX) $(ARCHFLAGS) $(LDFLAGS) -o $@ output.o $(LINKFLTKFORMS) $(LDLIBS)
$(OSX_ONLY) ../fltk-config --post $@
overlay$(EXEEXT): overlay.o
@ -398,6 +415,7 @@ pixmap$(EXEEXT): pixmap.o
pixmap_browser$(EXEEXT): pixmap_browser.o $(IMGLIBNAME)
echo Linking $@...
$(CXX) $(ARCHFLAGS) $(LDFLAGS) pixmap_browser.o -o $@ $(LINKFLTKIMG) $(LDLIBS)
$(OSX_ONLY) ../fltk-config --post $@
preferences$(EXEEXT): preferences.o
preferences.cxx: preferences.fl ../fluid/fluid$(EXEEXT)
@ -459,6 +477,7 @@ CubeView$(EXEEXT): CubeMain.o CubeView.o CubeViewUI.o
$(CXX) $(ARCHFLAGS) $(LDFLAGS) -o $@ \
CubeMain.o CubeView.o CubeViewUI.o \
$(LINKFLTKGL) $(LINKFLTK) $(GLDLIBS)
$(OSX_ONLY) ../fltk-config --post $@
CubeMain.o: CubeViewUI.h CubeView.h CubeViewUI.cxx
CubeView.o: CubeView.h
CubeViewUI.o: CubeViewUI.cxx CubeViewUI.h
@ -467,30 +486,37 @@ CubeViewUI.cxx: CubeViewUI.fl ../fluid/fluid$(EXEEXT)
cube$(EXEEXT): cube.o
echo Linking $@...
$(CXX) $(ARCHFLAGS) $(LDFLAGS) -o $@ cube.o $(LINKFLTKGL) $(LINKFLTK) $(GLDLIBS)
$(OSX_ONLY) ../fltk-config --post $@
fractals$(EXEEXT): fractals.o fracviewer.o
echo Linking $@...
$(CXX) $(ARCHFLAGS) $(LDFLAGS) -o $@ fractals.o fracviewer.o $(LINKFLTKGL) $(LINKFLTK) $(GLDLIBS)
$(OSX_ONLY) ../fltk-config --post $@
fullscreen$(EXEEXT): fullscreen.o
echo Linking $@...
$(CXX) $(ARCHFLAGS) $(LDFLAGS) -o $@ fullscreen.o $(LINKFLTKGL) $(LINKFLTK) $(GLDLIBS)
$(OSX_ONLY) ../fltk-config --post $@
glpuzzle$(EXEEXT): glpuzzle.o
echo Linking $@...
$(CXX) $(ARCHFLAGS) $(LDFLAGS) -o $@ glpuzzle.o $(LINKFLTKGL) $(LINKFLTK) $(GLDLIBS)
$(OSX_ONLY) ../fltk-config --post $@
gl_overlay$(EXEEXT): gl_overlay.o
echo Linking $@...
$(CXX) $(ARCHFLAGS) $(LDFLAGS) -o $@ gl_overlay.o $(LINKFLTKGL) $(LINKFLTK) $(GLDLIBS)
$(OSX_ONLY) ../fltk-config --post $@
shape$(EXEEXT): shape.o
echo Linking $@...
$(CXX) $(ARCHFLAGS) $(LDFLAGS) -o $@ shape.o $(LINKFLTKGL) $(LINKFLTK) $(GLDLIBS)
$(OSX_ONLY) ../fltk-config --post $@
cairo_test$(EXEEXT): cairo_test.o
echo Linking $@...
$(CXX) $(ARCHFLAGS) $(CAIROFLAGS) $(LDFLAGS) -o $@ cairo_test.o $(LINKFLTK) $(LINKFLTKCAIRO) $(GLDLIBS)
$(OSX_ONLY) ../fltk-config --post $@
#
# End of "$Id$".

View File

@ -136,14 +136,18 @@ int main(int argc, char **argv) {
fname = "../test/browser.cxx";
done = browser->load(fname);
}
#elif defined(USING_XCODE)
#elif defined(__APPLE__)
if ( i == argc )
{
char buf[2048];
strcpy(buf, argv[0]);
char *slash = strrchr(buf, '/');
if (slash)
#if defined(USING_XCODE)
strcpy(slash, "/../Resources/browser.cxx");
#else
strcpy(slash, "/../../../browser.cxx");
#endif
done = browser->load(buf);
}
#endif

View File

@ -27,7 +27,7 @@
# define chdir _chdir
# define putenv _putenv
# endif // !__WATCOMC__
#elif defined USING_XCODE
#elif defined __APPLE__
#include <ApplicationServices/ApplicationServices.h>
#include <unistd.h> // for chdir()
#include <stdio.h>
@ -272,7 +272,7 @@ void dobut(Fl_Widget *, long arg)
delete[] command;
delete[] copy_of_icommand;
#elif defined USING_XCODE
#elif defined __APPLE__
char *cmd = strdup(menus[men].icommand[bn]);
char *arg = strchr(cmd, ' ');
@ -283,22 +283,32 @@ void dobut(Fl_Widget *, long arg)
CFBundleRef app = CFBundleGetMainBundle();
CFURLRef url = CFBundleCopyBundleURL(app);
CFStringRef cc_app_path = CFURLCopyFileSystemPath(url, kCFURLPOSIXPathStyle);
CFRelease(url);
CFStringGetCString(cc_app_path, app_path, 2048, kCFStringEncodingUTF8);
CFRelease(cc_app_path);
if (*app_path) {
char *n = strrchr(app_path, '/');
if (n) {
#if defined USING_XCODE
*n = 0;
#endif
chdir(app_path);
}
}
if (arg) {
const char *fluidpath;
*arg = 0;
#if defined USING_XCODE
fl_filename_absolute(path, 2048, "../../../../test/");
fluidpath = "Fluid.app";
#else
strcpy(path, app_path); strcat(path, "/");
fluidpath = "../fluid/fluid.app";
#endif
if (strcmp(cmd, "../fluid/fluid")==0) {
fl_filename_absolute(path, 2048, "../../../../test/");
sprintf(command, "open Fluid.app --args %s%s", path, arg+1);
sprintf(command, "open %s --args %s%s", fluidpath, path, arg+1);
} else {
fl_filename_absolute(path, 2048, "../../../../test/");
sprintf(command, "open %s.app --args %s%s", cmd, path, arg+1);
}
} else {

View File

@ -10,7 +10,7 @@
#
@main:Widget\nTests...:@x
@x:Fl_Browser:browser
@x:Fl_Browser:browser browser.cxx
@x:Fl_Input:input
@x:Fl_Output:output
@x:Fl_Button:radio