Thank you Eelco. Along with David's help it helped a lot.
Juw Won park

On Fri, 2003-02-14 at 02:14, Eelco Van Vliet wrote:
> 
> I have created my own makefile
> 
> It searches and compiles all source found below the ./src directory, and
> put objects to the ./obj directoy, executable to the ./bin directory and
> mdf file to the ./mdf directory.
> 
> Probably you should make some small changes. I use some libraries you
> don't have. And the DX BASE should be adjusted.
> 
> Try : make help
> 
> for some information on make options
> 
> Hopes this helps
> 
> Regards
> 
> Eelco van Vloet
> 
> 
> On Fri, 14 Feb 2003, Juw Won Park wrote:
> 
> > Hi
> >
> > Now I'm trying to compile and run MODULE.
> > Can someone post makefile for linux? (My linux version is RedHat 8.0)
> >
> > I'm using makefile that came with opendx4.2.0 and it gives me the error
> > below.
> >
> > ==================
> > %gmake hello
> > gcc -I/usr/local/dx/include  -g -O2 -Wall -g -O2 -I/usr/X11R6/include
> > -D_GNU_SOURCE userhello.c hello.c -L/usr/local/dx/lib_linux -lDX -lnsl
> > -lnetcdf -lcdf -lXpm -ldl -lXm -lXp -lGLU -lGL -L/usr/lib
> > -L/usr/X11R6/lib -L/usr/local/lib -lMagick -ljbig -ldf -lmpeg2 -ltiff
> > -lfreetype -ljasper -ljpeg -lpng -ldpstk -ldps -lXext -lXt -lSM -lICE
> > -lX11 -lbz2 -lxml2 -lz -lpthread -lm -Wl,-export-dynamic -o dxexec
> > /usr/bin/ld: cannot find -lnetcdf
> > collect2: ld returned 1 exit status
> > gmake: *** [hello] Error 1
> > ====================
> >
> > Regards,
> > Juw Won
> >
> >
> ----
> 

> # Opendx make file
> # by : Eelco van Vliet
> #
> # Only the modules with a corresponding mdf-file in the mdf-directory are
> # compiled and linked 
> #
> # import the general dx configutation make file
> BASE          = /opt/dx-4.2.0/dx
> include $(BASE)/lib_$(DXARCH)/arch.mak
> BIN           = $(BASE)/bin
> #
> # define my own library and include directories
> MYLIBDIR      =${HOME}/prog/mylib
> MYINCLDIR=${HOME}/prog/myincl
> #
> # define some local directories 
> SRCDIR        = ./src
> OBJDIR        = ./obj
> EXEDIR        = ./bin
> MDFDIR        = ./mdf
> #
> # retrieve my own libraries and include  files 
> MYINCLFILES:=$(wildcard $(MYINCLDIR)/*.h )
> MYLIBSFILES:=$(wildcard $(MYLIBDIR)/*.a)
> #
> # change the $MYLIBDIR/libbla.a --> -lbla 
> MYLIBS=$(patsubst lib%,-l%, $(notdir $(patsubst %.a,%,$(MYLIBSFILES)))) 
> MISCLIBS= -lsfftw
> USERLIBS= $(MISCLIBS) $(MYLIBS)
> #
> # define the other user added libs and the specific opendx libs (remove
> # non-valid libs with sed)
> DXLIBS= -lDX $(DX_GL_LINK_LIBS) $(DXEXECLINKLIBS) 
> DXLIBS:=$(shell echo $(DXLIBS)| sed -e 's/-lXm//')
> #
> # define executable name in case that stand alone exe is build
> DXEXEC        = dxexec
> #
> # define all include files and libs to be added
> INCLFILES=$(MYINCLFILES)
> LIBSFILES=$(MYLIBSFILES)
> #
> # the compile and link flags
> CFLAGS = -I./ -I$(BASE)/include $(DXCFLAGSDEBUG) -I$(MYINCLDIR) 
> -I/opt/fftw-2.1.3/include
> LDFLAGS = -L$(BASE)/lib_$(DXARCH) -L$(MYLIBDIR) -L/opt/fftw-2.1.3/lib
> #
> # set VPATH
> VPATH:=$(wildcard $(SRCDIR)/* )
> VPATH:=.:$(shell echo $(VPATH)|sed -e 's/ /:/g')
> #
> # obtain all the module files based on the mdf file present in ./mdf
> MDFS=$(shell find $(MDFDIR) -name "*.mdf")
> ROOTS=$(patsubst %.mdf,%,$(notdir $(MDFS)))
> OBJS=$(addprefix $(OBJDIR)/,$(addsuffix .o,$(ROOTS)))
> EXES=$(addprefix $(EXEDIR)/,$(ROOTS))
> #
> ########### ########### ########### ########### ########### ########### 
> # from here, all the dependcies
> # target: prerequisite 
> # $@ = target,  $< prerequisite, $(@F) = filebase of target
> ########### ########### ########### ########### ########### ########### 
> #
> all:  $(EXES)
> #
> # rules to link the executables 
> $(EXEDIR)/%: $(OBJDIR)/%.o $(MDFDIR)/%.mdf
>       @echo compiling $(@F).mdf
>       @$(BIN)/mdf2c -m $(MDFDIR)/$(@F).mdf > user.c
>       @$(CC) $(CFLAGS) -c user.c
>       @echo "linking   $@"
>       @$(SHARED_LINK) $(DXABI) $(LDFLAGS) -o $@ $< user.o $(DX_RTL_LDFLAGS) 
> $(SYSLIBS) $(USERLIBS)
>       @rm user.[oc] 
> #
> # Make the object files from the .c files
> $(OBJDIR)/%.o: %.c $(INCLFILES) $(LIBSFILES)
>       @echo compiling $<
>       @$(CC) $(DXABI) $(DX_RTL_CFLAGS) $(CFLAGS) -c $< -o $@
> #
> ########### ########### ########### ########### ########### ########### 
> # from here, all the other commands
> ########### ########### ########### ########### ########### ########### 
> #
> #show:
> #     @echo $(LIBSFILES)
> #
> # rules to create new dx executable
> exe: $(OBJS)
>       @echo "making  user.mdf"
>       cat $(MDFS) > user.mdf
>       $(BIN)/mdf2c user.mdf > user.c
>       $(CC) $(CFLAGS) -c user.c
>       @echo linking executable $(DXEXEC)
>       $(CC) $(LDFLAGS) $(OBJS) user.o $(DXLIBS) $(USERLIBS) -o 
> $(EXEDIR)/$(DXEXEC)
> #
> # a command to run the user module
> edit: 
>       @cat $(MDFS) > user.mdf
>       dx -edit $(FILE) -mdf user.mdf &
> #
> # run in executing mode with a given net file
> run: 
>       @cat $(MDFS) > user.mdf
>       dx -image -menubar $(FILE) -mdf user.mdf &
> #
> # run in script mode
> runscript: 
>       @cat $(MDFS) > user.mdf
>       dx -image -menubar $(FILE) -mdf user.mdf -script & 
> #
> # edit the inboard executable
> editexe: 
>       @cat $(MDFS) |awk '$$1!="LOADABLE" {print $0}' > user.mdf
>       dx -edit -exec $(EXEDIR)/$(DXEXEC) -mdf user.mdf &
> #
> # run the inboard executable
> runexe: 
>       @cat $(MDFS) |awk '$$1!="LOADABLE" {print $0}' > user.mdf
>       dx -image -menubar -exec $(EXEDIR)/$(DXEXEC) -mdf user.mdf &
> #
> debug: 
> #     @cat $(MDFS) > user.mdf
> #     dx -uionly -mdf user.mdf &
> #     ddd dx -edit -mdf user.mdf &
> #
> # run the inboard executable in debugging mode
> debugin: 
>       @cat $(MDFS) |awk '$$1!="LOADABLE" {print $0}' > user.mdf
>       dx -uionly $(FILE) -exec $(EXEDIR)/$(DXEXEC) -mdf user.mdf &
>       ddd $(EXEDIR)/$(DXEXEC) &
> #
> clean:
>                 @echo cleaning objects...
>                       @find . -name "*.o" -exec rm {} \;
>                       @find . -name "user.*" -exec rm {} \;
> #
> back:
>                       @echo backing up net files
>                       @tar uvf Backup.tar ./net/*.net ./net/*.cfg  ./Makefile
>                       @tar uvf Backup.tar ./macros/*.net ./Makefile
> showback:
>                       @echo showing backup net files
>                       tar tvf Backup.tar
> getback:
>                  @ls $(FILE).net $(FILE).cfg | awk \
>                                               '{printf("mv %s 
> ~/trashbin\n",$$0)}' |bash
>                       @tar xf Backup.tar -O $(FILE).net | awk\
>                                       '{if ($$0~/time:/) OUT=0;               
> \
>                                         if ($$0~/time:/ && $$0 ~ /$(TIME)/) 
> OUT = 1;  \
>                                         if (OUT == 1) print $$0}' > 
> $(FILE).net
>                       @tar xf Backup.tar -O $(FILE).cfg | awk\
>                                       '{if ($$0~/time:/) OUT=0;               
> \
>                                         if ($$0~/time:/ && $$0 ~ /$(TIME)/) 
> OUT = 1;  \
>                                         if (OUT == 1) print $$0}' > 
> $(FILE).cfg
> #
> cleanall:
>       @make clean     
>       @echo cleaning binaries...
>       @ls bin | awk '{printf("mv ./bin/%s ~/trashbin\n",$$0)}' |bash
> #
> help:
>                 @echo Makefile options
>                 @echo "make                           : compile and link 
> objects to loadable moldulels"
>                 @echo "make exe                       : compile and link 
> objects to inboard executable"
>                 @echo "make edit [FILE=<netfile>]     : edit DX netfile with 
> loadable modules"
>                 @echo "make editexe [FILE=<netfile>]  : edit DX netfile as 
> inboard executable"
>                 @echo "make run [FILE=<netfile>]      : run DX netfile with 
> loadable modules"
>                 @echo "make runexe [FILE=<netfile>]   : run DX netfile as 
> inboard executable"
>                 @echo "make debug [FILE=<netfile>]    : debug a opendx as 
> inboard executable"
>                 @echo "make clean                     : remove all object and 
> bak files"
>                 @echo "make cleanall                  : clean + remove all 
> loadable executables"
>                 @echo "make back                      : makes a backup of all 
> the .net and .cfg files"
>                 @echo "make showback                  : shows a list of all 
> the back up files"
>                 @echo "make getback FILE=<filename> TIME=<timestamp> :"
>                 @echo "                 restores the  back up file <filename> 
> (without extension)"
>                 @echo "                 and the given time stamp"

Reply via email to