--- Modified erd/src/erdinternal.c because Cygwin appears to define fpos_t as a long (it is not a structure, as with Linux) BASE/MSX/ERD/WDSSIM ------------------- Cygwin makefiles had been building code using MingW. This was confusing, as one might expect such makefiles to produce cygwin DLLs and executables and not native windows (i.e. MingW) DLLs and executables. Also, this was a problem because sometimes one would prefer to have Cygwin DLLs because one wants to produce Cygwin executables using them. Practically, it can be more convenient to produce Cygwin executables for a Windows target machine, just because the Cygwin environment is closer to a complete Unix environment. In fact the motivation for this was the need to build WDSSim for a windows target, and this led to annoying complications with libxml2 libraries and include files when trying to build everything as native Windows using MingW. Now, build/Cygwin makefiles are producing Cygwin DLLs/executables and NOT native windows DLLs/executables. The old Cygwin-MingW makefiles have been retained, but placed in new MingW build subdirectories for those cases when one really wants to use MingW to build for a native windows target. FILE NAME CONVENTIONS --------------------- All this is terribly confusing, and we wish for a plain old Linux environment. With regard to file and library names, there is significant potential to confuse things. Accordingly we have defined the following standard naming convention that eventually everything in ENGCVS should use. If one has a library called "mylib", the names of the various files should be the following, BY CONVENTION (i.e. they don't have to be these names, but if they aren't, then you'll just confuse the heck out of the rest of us). CYGWIN DLL (shared library) cygmylib.dll (DLL) (note 'cyg' prefix indicates it is a cygwin object) cygmylib.def (DEF) libcygmylib.dll.a (import lib) (note '.dll' indicates it is an import library pointing to a DLL) CYGWIN ARCHIVE libcygmylib.a (object archive) (note the absence of '.dll' indicates it is an object archive an not a DLL import lib) MINGW DLL (shared library) mylib.dll (DLL) (note this is a native windows DLL, and the absence of 'cyg' shows that) mylib.def (DEF) libmylib.dll.a (gcc import lib) mylib.lib (LIB) (msvc import lib, pointing to same DLL - produced using msvc LIB.EXE) MINGW ARCHIVE libmylib.a (object archive) LINUX SO (shared library) libmylib.so (SO - shared object library, Linux analogue to windows DLL) (No DEF or import library required) LINUX ARCHIVE libmylib.a (object archive) Note how these names uniquely specify the target (cygwin, windows, Linux) as well as the file type (DLL, SO, DEF, import lib, object archive). Or at least mostly uniquely - note that the object archive is the same name on Linux and under MinGW. This shouldn't be problem since Linux object archives shouldn't ever be present on Windows machines, and vice-versa. And if they are (by mistake/accident), the codes won't link or run so there will be definitive identification of the error. Finally, for an executable code "mycommand" we have the following CONVENTION: mycommand.exe (Windows/MingW or Windows/MSVC) cygmycommand.exe (Windows/Cygwin) mycommand (Linux) git-svn-id: https://epanet.svn.sourceforge.net/svnroot/epanet/BASE/trunk@221 c320cabd-cc23-0410-96d8-e60fbf53ed7f
131 lines
4.7 KiB
Makefile
Executable File
131 lines
4.7 KiB
Makefile
Executable File
# Cygwin Makefile for EPANET
|
|
|
|
# This will build EPANET as a cygwin DLL and import
|
|
# library (cygepanet_gcc_<Rev>.dll/libcygepanet_gcc_<Rev>.dll.a) under Cygwin/gcc,
|
|
# and a standalone executable (cygepanet_gcc_<Rev>.exe).
|
|
# <Rev> is the atomic revision number of the EPANET SVN repo,
|
|
# so the results of each build can be unambiguously tracked to a repo Rev.
|
|
# The current release of the Cygwin environment can be
|
|
# obtained from http://www.cygwin.com
|
|
|
|
# The following targets are defined (for execution in
|
|
# the build directory under the Cygwin environment):
|
|
# make
|
|
# -Builds cygepanet_gcc_<Rev>.dll, cygepanet_gcc_<Rev>.def, libcygepanet_gcc_<Rev>.dll.a,
|
|
# cygepanet_gcc_<Rev>.exe
|
|
# make install
|
|
# -Creates shell wrapper runcygepanet_<Rev>.sh that
|
|
# executes cygepanet_gcc_<Rev>.exe.
|
|
# The runcygepanet_<Rev>.sh wrapper simply exports
|
|
# environment variables so that the DLL is found at runtime,
|
|
# allowing you to specify your own locations for installing
|
|
# the DLL.
|
|
# -Installs cygepanet_gcc_<Rev>.dll, cygepanet_gcc_<Rev>.exe, and runcygepanet_<Rev>.sh
|
|
# in <prefix>/bin, where <prefix> defaults to ~ (and can be set
|
|
# below to something different - see "Install directories")
|
|
# -Installs libcygepanet_gcc_<Rev>.dll.a (import library), and cygepanet_gcc_<Rev>.def,
|
|
# in <prefix>/lib
|
|
# -Installs epanet2.h in <prefix>/include. This is the required
|
|
# header file for the EPANET programmer's toolkit, and thus
|
|
# <prefix>/include should be on your CPP include search path
|
|
# for subsequent use of the toolkit and linking with the import
|
|
# library libcygepanet_gcc_<Rev>.dll.a.
|
|
# make clean
|
|
# -Removes object and library files, returning the build directory
|
|
# to its pristine state.
|
|
|
|
SHELL = /bin/sh
|
|
|
|
# C H A N G E H E R E A S N E E D E D
|
|
# You may wish to change the install path 'prefix',
|
|
# or the compiler flags, but these defaults should be fine.
|
|
|
|
# Target filenames
|
|
# svnname.sh constructs a name: <prefix><root><Rev><postfix>
|
|
# where <Rev> is the atomic revision number of the svn repo.
|
|
epanetsvnpath = ../../..
|
|
epanetrootname := $(shell ../svnname.sh $(epanetsvnpath) "" cygepanet_gcc_ "")
|
|
dllname := $(epanetrootname).dll
|
|
defname := $(epanetrootname).def
|
|
implibname = lib$(dllname).a
|
|
exename := $(epanetrootname)
|
|
# Shell wrapper
|
|
runcmdtemplate = runepanet.sh.template
|
|
runcmdname = $(shell ../svnname.sh $(epanetsvnpath) "" runcygepanet_ .sh)
|
|
# Location of EPANET toolkit includes
|
|
epanetincludedir = ../../include
|
|
# Search path for sources
|
|
epanetsrcdir = ../../src
|
|
VPATH = $(epanetsrcdir):$(epanetincludedir)
|
|
|
|
# Install directories
|
|
prefix = ~
|
|
exec_prefix = $(prefix)
|
|
srcdir = .
|
|
libdir = $(exec_prefix)/lib
|
|
bindir = $(exec_prefix)/bin
|
|
includedir = $(prefix)/include
|
|
datarootdir = $(prefix)/share
|
|
docdir = $(datarootdir)/doc/epanet
|
|
|
|
# Compiler and flags
|
|
CC = /bin/gcc
|
|
dlltool = /bin/dlltool
|
|
CFLAGS = -g -O
|
|
CPPFLAGS = -I $(srcdir) -I $(epanetincludedir)
|
|
LDFLAGS = -L . -W1,-rpath,$(libdir) -lm
|
|
|
|
# Installer
|
|
INSTALL = install
|
|
INSTALL_PROGRAM = $(INSTALL)
|
|
INSTALL_DATA = $(INSTALL) -m 644
|
|
|
|
# EPANET object files
|
|
epanet_objs=hash.o hydraul.o inpfile.o input1.o input2.o \
|
|
input3.o mempool.o output.o quality.o report.o \
|
|
rules.o smatrix.o
|
|
# Epanet header files
|
|
epanet_heads=enumstxt.h funcs.h hash.h mempool.h text.h toolkit.h types.h vars.h
|
|
epanet_main_heads=epanet2.h
|
|
# Epanet main program
|
|
epanet_main=epanet
|
|
|
|
.PHONY: all
|
|
all: $(dllname) $(exename)
|
|
|
|
$(dllname): $(epanet_objs)
|
|
# $(dlltool) -z $(defname) --dllname $(dllname) --output-lib $(implibname) $^
|
|
# $(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ $(defname) $^
|
|
$(CC) $(CFLAGS) $(CPPFLAGS) -D SOL -c $(epanetsrcdir)/$(epanet_main).c
|
|
$(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ $(epanet_main).o $^ -Wl,--output-def,$(defname)
|
|
$(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ $(epanet_main).o $^ -Wl,--kill-at
|
|
$(dlltool) -d $(defname) --dllname $@ --output-lib $(implibname) --kill-at
|
|
|
|
$(exename): $(epanet_objs)
|
|
$(CC) $(CFLAGS) $(CPPFLAGS) -D CLE -c $(epanetsrcdir)/$(epanet_main).c
|
|
$(CC) $(CFLAGS) -o $@ $(epanet_main).o $^ $(LDFLAGS)
|
|
|
|
$(epanet_objs): $(epanet_heads)
|
|
|
|
.PHONY: install
|
|
install:
|
|
cat $(runcmdtemplate) | sed 's|libdir|$(bindir)|' \
|
|
| sed 's|exename|$(bindir)/$(exename)|' \
|
|
> $(runcmdname)
|
|
$(INSTALL_PROGRAM) -D $(exename) $(bindir)/$(exename)
|
|
$(INSTALL_PROGRAM) -D $(dllname) $(bindir)/$(dllname)
|
|
$(INSTALL_PROGRAM) -D $(defname) $(libdir)/$(defname)
|
|
$(INSTALL_PROGRAM) -D $(implibname) $(libdir)/$(implibname)
|
|
$(INSTALL_DATA) -D $(epanetincludedir)/epanet2.h $(includedir)/epanet2.h
|
|
$(INSTALL_PROGRAM) -D $(runcmdname) $(bindir)/$(runcmdname)
|
|
|
|
.PHONY: uninstall
|
|
uninstall:
|
|
|
|
.PHONY: check
|
|
check:
|
|
|
|
.PHONY: clean
|
|
clean:
|
|
-/bin/rm *.o $(dllname) $(defname) $(implibname) $(exename).exe $(runcmdname)
|