Commit ccf102e5 authored by Pierre DAVID's avatar Pierre DAVID

Simplify various Makefiles

parent ae819c48
# for packaging and libnetmagis.tcl
VERSION = 3.0.0alpha
DESTDIR =
PREFIX = /local/netmagis
......@@ -28,7 +31,8 @@ SUBST = $(TCLSH) \
$(ETCDIR)/netmagis.conf \
$(BINDIR)/netmagis-config
DIRS = \
VARS = \
VERSION=$(VERSION) \
BINDIR=$(BINDIR) \
SBINDIR=$(SBINDIR) \
ETCDIR=$(ETCDIR) \
......@@ -48,9 +52,6 @@ TCLCONF = /usr/local/lib/tcl8.6/tclConfig.sh
TCLCFLAGS = `(cat $(TCLCONF) ; echo 'echo "$$TCL_INCLUDE_SPEC"')|sh`
TCLLFLAGS = `(cat $(TCLCONF) ; echo 'echo "$$TCL_LIB_SPEC $$TCL_LIBS"')|sh`
# for packaging and libnetmagis.tcl
VERSION = 2.3.1
# build debian package for the following architectures
DEBIAN_PKG_ARCH = i386
# default debian distribution
......@@ -85,51 +86,51 @@ build: build-www build-topo
# NEARLY OBSOLETE
build-www:
cd www ; make $(DIRS) SUBST="$(SUBST)" TCLSH=$(TCLSH) \
cd www ; $(MAKE) $(VARS) SUBST="$(SUBST)" TCLSH=$(TCLSH) \
TCLCFLAGS="$(TCLCFLAGS)" TCLLFLAGS="$(TCLLFLAGS)" build
build-server:
cd server ; make $(DIRS) SUBST="$(SUBST)" TCLSH=$(TCLSH) build
cd server ; $(MAKE) $(VARS) SUBST="$(SUBST)" TCLSH=$(TCLSH) build
build-topo:
cd topo ; make build
cd topo ; $(MAKE) build
install: install-common install-server install-servers install-utils \
install-detecteq install-topo install-metro install-www
install-common:
cd common ; \
make $(DIRS) SUBST="$(SUBST)" TCLSH=$(TCLSH) VERSION=$(VERSION) install
$(MAKE) $(VARS) SUBST="$(SUBST)" TCLSH=$(TCLSH) VERSION=$(VERSION) install
install-server:
cd server ; make $(DIRS) SUBST="$(SUBST)" TCLSH=$(TCLSH) VERSION=$(VERSION) install
cd server ; $(MAKE) $(VARS) SUBST="$(SUBST)" TCLSH=$(TCLSH) VERSION=$(VERSION) install
install-servers:
cd servers ; make $(DIRS) SUBST="$(SUBST)" TCLSH=$(TCLSH) install
cd servers ; $(MAKE) $(VARS) SUBST="$(SUBST)" TCLSH=$(TCLSH) install
# NEARLY OBSOLETE
install-www: build-www
cd www ; make $(DIRS) SUBST="$(SUBST)" TCLSH=$(TCLSH) \
cd www ; $(MAKE) $(VARS) SUBST="$(SUBST)" TCLSH=$(TCLSH) \
TCLCFLAGS="$(TCLCFLAGS)" TCLLFLAGS="$(TCLLFLAGS)" install
install-utils:
cd utils ; make $(DIRS) SUBST="$(SUBST)" TCLSH=$(TCLSH) install
cd utils ; $(MAKE) $(VARS) SUBST="$(SUBST)" TCLSH=$(TCLSH) install
install-topo: build-topo
cd topo ; make $(DIRS) SUBST="$(SUBST)" TCLSH=$(TCLSH) install
cd topo ; $(MAKE) $(VARS) SUBST="$(SUBST)" TCLSH=$(TCLSH) install
install-detecteq:
cd detecteq ; make $(DIRS) SUBST="$(SUBST)" TCLSH=$(TCLSH) install
cd detecteq ; $(MAKE) $(VARS) SUBST="$(SUBST)" TCLSH=$(TCLSH) install
install-metro:
cd metro ; make $(DIRS) SUBST="$(SUBST)" TCLSH=$(TCLSH) install
cd metro ; $(MAKE) $(VARS) SUBST="$(SUBST)" TCLSH=$(TCLSH) install
# PROBLEM
install-netmagis.org: build-www
cd doc/netmagis.org ; make $(DIRS) SUBST="$(SUBST)" TCLSH=$(TCLSH) install
cd doc/netmagis.org ; $(MAKE) $(VARS) SUBST="$(SUBST)" TCLSH=$(TCLSH) install
install-devtools:
cd devtools ; make $(DIRS) SUBST="$(SUBST)" TCLSH=$(TCLSH) install
cd devtools ; $(MAKE) $(VARS) SUBST="$(SUBST)" TCLSH=$(TCLSH) install
distrib: clean
rm -rf /tmp/netmagis-$(VERSION)
......@@ -150,8 +151,8 @@ freebsd-ports:
echo "once netmagis-$(VERSION).tar.gz is on the master site" ; \
exit 1 ; \
fi
for i in pkg/freebsd/netmagis-* ; do (cd $$i ; make clean) ; done
cd pkg/freebsd/netmagis-common ; make makesum
for i in pkg/freebsd/netmagis-* ; do (cd $$i ; $(MAKE) clean) ; done
cd pkg/freebsd/netmagis-common ; $(MAKE) makesum
tar -czf netmagis-freebsd-ports-$(VERSION).tar.gz -C pkg/freebsd .
debian-packages:
......@@ -160,26 +161,26 @@ debian-packages:
echo "once netmagis-$(VERSION).tar.gz is on the master site" ; \
exit 1 ; \
fi
cd pkg/debian ; make VERSION=$(VERSION) release
cd pkg/debian ; $(MAKE) VERSION=$(VERSION) release
debian-packages-other-arch:
cd pkg/debian ; \
for arch in $(DEBIAN_PKG_ARCH) ; do \
make VERSION=$(VERSION) ARCH=$$arch release-arch ; \
$(MAKE) VERSION=$(VERSION) ARCH=$$arch release-arch ; \
done
debian-repo:
pkg/debian/update-repo $(VERSION) pkg/debian $(DEBIAN_DISTRIB) $(REPODIR)
clean:
cd common ; make clean
cd server ; make clean
cd servers ; make clean
cd www ; make clean
cd utils ; make clean
cd detecteq ; make clean
cd topo ; make clean
cd metro ; make clean
cd common ; $(MAKE) clean
cd server ; $(MAKE) clean
cd servers ; $(MAKE) clean
cd www ; $(MAKE) clean
cd utils ; $(MAKE) clean
cd detecteq ; $(MAKE) clean
cd topo ; $(MAKE) clean
cd metro ; $(MAKE) clean
rm -f netmagis-*.tar.gz
nothing:
......@@ -18,7 +18,7 @@ install:
$(NINSTALL) -m 0644 -e "s/%NMVERSION%/$(VERSION)/" \
$(SUBST) libnetmagis.tcl $(DESTDIR)$(NMLIBDIR)
mkdir -p $(DESTDIR)$(NMLIBDIR)/pkgtcl
cd pkgtcl && make $(DIRS) TCLSH=$(TCLSH) clean install
cd pkgtcl && $(MAKE) TCLSH=$(TCLSH) clean install
mkdir -p $(DESTDIR)$(NMLIBDIR)/msgs
tar cf - msgs | tar xvf - -C $(DESTDIR)$(NMLIBDIR)
......
......@@ -5,7 +5,7 @@ build:
install: build
@echo ">>> Making install in `pwd`"
cd syslog ; make $(DIRS) install
cd radius ; make $(DIRS) install
cd syslog ; $(MAKE) install
cd radius ; $(MAKE) install
clean:
......@@ -5,6 +5,6 @@ build:
install:
@echo ">>> Making install in `pwd`"
cd tests ; make $(DIRS) install
cd tests ; $(MAKE) install
clean:
......@@ -9,9 +9,9 @@ build:
install:
@echo ">>> Making install in `pwd`"
cd bin ; make $(DIRS) install
cd lib ; make $(DIRS) install
cd ws ; make $(DIRS) install
cd bin ; $(MAKE) install
cd lib ; $(MAKE) install
cd ws ; $(MAKE) install
mkdir -p $(DESTDIR)$(NMXMPDIR)
$(NINSTALL) -m 0644 \
-e "s|%BINDIR%|$(BINDIR)|" \
......
......@@ -2,16 +2,16 @@ NINSTALL = ../ninstall
build:
@echo ">>> Making build in `pwd`"
cd lib ; make build
cd lib ; $(MAKE) build
install:
@echo ">>> Making install in `pwd`"
cd etc ; make $(DIRS) install
cd bin ; make $(DIRS) install
cd lib ; make $(DIRS) SUBST="$(SUBST)" VERSION=$(VERSION) install
cd www ; make NMLIBDIR=$(NMLIBDIR) install
cd examples ; make $(DIRS) install
cd etc ; $(MAKE) install
cd bin ; $(MAKE) install
cd lib ; $(MAKE) install
cd www ; $(MAKE) install
cd examples ; $(MAKE) install
mkdir -p $(DESTDIR)$(NMVARDIR)/dbdump
clean:
cd lib ; make clean
cd lib ; $(MAKE) clean
......@@ -14,5 +14,6 @@ install:
mkdir -p $(DESTDIR)$(BINDIR)
$(NINSTALL) -m 0755 \
-e "s|%NMLIBDIR%|$(NMLIBDIR)|" \
-e "s|%VERSION%|$(VERSION)|" \
-e "s|%BINDIR%|$(BINDIR)|" $(SUBST) \
$(SCRIPTS) $(DESTDIR)$(BINDIR)
#!/usr/bin/tclsh8.6
#!%TCLSH%
set pkgdir %NMLIBDIR%/pkgtcl
set pkgdir ../lib/pkgtcl
set conf(conffile) %CONFFILE%
set conf(addr) 0.0.0.0
set conf(port) 8080
set conf(libdir) %NMLIBDIR%
set conf(files) %NMLIBDIR%/www
set conf(minw) 2
set conf(maxw) 4
set conf(idle) 30
set conf(version) %VERSION%
lappend auto_path $pkgdir
package require scgi
set conf(usage) {usage: %s [-h][-d][-c conf][-a addr][-p port][-l libdir][-f files][-m min][-x max][-i idle][-v vers]
-h: this help message
-d: debug
-c conf: path to the configuration file
-a addr: listening address (e.g. 0.0.0.0)
-p port: listening port (e.g. 8080)
-l libdir: path to the libdir (with subdirectories worker/ and pkgtcl/)
-f files: path to the directory containing static files
-m min: minimum number of workers threads (e.g. 2)
-x max: maximum number of workers threads (e.g. 4)
-i idletime: maximum time in sec before a worker thread exists (e.g. 30)
-v vers: application version for schema checking (e.g. 3.0.0alpha)
}
set conffile ./netmagis.conf
proc usage {} {
global conf
set wrkrdir %NMLIBDIR%/worker
set wrkrdir ../lib/worker
puts stderr [format $conf(usage) $argv0]
exit 1
}
::scgi::start \
-debug true \
-minworkers 1 \
"set conffile $conffile
set wrkdir $wrkrdir
lappend auto_path $pkgdir
source $wrkrdir/worker.tcl" \
proc main {argv0 argv} {
global conf
#
# Argument checking
#
set debug false
set conffile $conf(conffile)
set addr $conf(addr)
set port $conf(port)
set libdir $conf(libdir)
set files $conf(files)
set minw $conf(minw)
set maxw $conf(maxw)
set idle $conf(idle)
set version $conf(version)
while {[llength $argv] > 0} {
set a [lindex $argv 0]
switch -glob -- $a {
-h {
usage
}
-d {
set debug true
set argv [lreplace $argv 0 0]
}
-c {
set conffile [lindex $argv 1]
set argv [lreplace $argv 0 1]
}
-a {
set addr [lindex $argv 1]
set argv [lreplace $argv 0 1]
}
-p {
set port [lindex $argv 1]
set argv [lreplace $argv 0 1]
}
-l {
set libdir [lindex $argv 1]
set argv [lreplace $argv 0 1]
}
-f {
set files [lindex $argv 1]
set argv [lreplace $argv 0 1]
}
-m {
set minw [lindex $argv 1]
set argv [lreplace $argv 0 1]
}
-x {
set maxw [lindex $argv 1]
set argv [lreplace $argv 0 1]
}
-i {
set idle [lindex $argv 1]
set argv [lreplace $argv 0 1]
}
-v {
set version [lindex $argv 1]
set argv [lreplace $argv 0 1]
}
-* {
puts stderr "Unknown option '$a'"
usage
}
default {
break
}
}
}
if {[llength $argv] > 0} then {
usage
}
array set wconf [list \
conffile $conffile \
libdir $libdir \
files $files \
version $version \
]
global auto_path
lappend auto_path $libdir/pkgtcl
package require scgi
::scgi::start \
-debug $debug \
-myaddr $addr \
-myport $port \
-minworkers $minw \
-maxworkers $maxw \
-idletime $idle \
"set conf(conffile) $conffile
set conf(libdir) $libdir
set conf(files) $files
set conf(version) $version
lappend auto_path $libdir/pkgtcl
source $libdir/worker/worker.tcl" \
"handle-request"
}
exit [main $argv0 $argv]
......@@ -7,9 +7,9 @@ install:
mkdir -p $(DESTDIR)$(NMXMPDIR)
$(NINSTALL) -m 0644 -e "s|%SBINDIR%|$(SBINDIR)|" $(SUBST) \
$(FILES) $(DESTDIR)$(NMXMPDIR)
cd no-view ; make $(DIRS) install
cd with-views ; make $(DIRS) install
cd no-view ; $(MAKE) install
cd with-views ; $(MAKE) install
clean:
cd no-view ; make clean
cd with-views ; make clean
cd no-view ; $(MAKE) clean
cd with-views ; $(MAKE) clean
......@@ -2,15 +2,15 @@ NINSTALL = ../../ninstall
build:
@echo ">>> Making build in `pwd`"
cd pkgtcl ; make build
cd pkgtcl ; $(MAKE) build
install:
@echo ">>> Making install in `pwd`"
mkdir -p $(DESTDIR)$(NMLIBDIR)
cd pkgtcl ; make DIRS="$(DIRS)" SUBST="$(SUBST)" VERSION=$(VERSION) install
cd worker ; make DIRS="$(DIRS)" SUBST="$(SUBST)" install
cd upgrade ; make $(DIRS) SUBST="$(SUBST)" install
cd pkgtcl ; $(MAKE) install
cd worker ; $(MAKE) install
cd upgrade ; $(MAKE) install
tar cf - sql* *.sql | tar xf - -C $(DESTDIR)$(NMLIBDIR)
clean:
cd pkgtcl ; make clean
cd pkgtcl ; $(MAKE) clean
......@@ -2,10 +2,10 @@ NINSTALL = ../../../ninstall
TCLSH = /usr/local/bin/tclsh
FILES = \
scgi.tcl \
pgdb.tcl \
lconf.tcl \
dbconf.tcl \
lconf.tcl \
pgdb.tcl \
scgi.tcl \
build: pkgIndex.tcl
@echo ">>> Making build in `pwd`"
......@@ -17,10 +17,9 @@ pkgIndex.tcl: $(FILES)
install: build
@echo ">>> Making install in `pwd`"
mkdir -p $(DESTDIR)$(NMLIBDIR)/pkgtcl
for F in *.tcl ; do \
$(NINSTALL) -m 0644 \
-e "s|%NMVERSION%|$(VERSION)|" \
$(SUBST) $$F $(DESTDIR)$(NMLIBDIR)/pkgtcl ; \
$(SUBST) \
$(FILES) $(DESTDIR)$(NMLIBDIR)/pkgtcl ; \
done
clean:
......
......@@ -4,19 +4,23 @@ TCLSH = /usr/local/bin/tclsh
FILES = \
worker.tcl \
libworker.tcl \
hdl-admin.tcl \
hdl-dhcpranges.tcl \
hdl-domains.tcl \
hdl-files.tcl \
hdl-hinfos.tcl \
hdl-login.tcl \
hdl-names.tcl \
hdl-networks.tcl \
hdl-views.tcl \
build:
@echo ">>> Making build in `pwd`"
cd msgs && $(MAKE) build
install: ################## build
@echo ">>> Making install in `pwd`"
mkdir -p $(DESTDIR)$(NMLIBDIR)/worker
for F in $(FILES) ; do \
$(NINSTALL) -m 0644 \
-e "s|%NMLIBDIR%|$(NMLIBDIR)|" \
$(SUBST) \
$$F $(DESTDIR)$(NMLIBDIR)/worker ; \
done
$(NINSTALL) -m 0644 $(SUBST) \
$(FILES) $(DESTDIR)$(NMLIBDIR)/worker ; \
cd msgs && $(MAKE) install
......@@ -23,7 +23,7 @@ api-handler get {/files/([-a-zA-Z0-9][-a-zA-Z0-9.]*:name)} yes {
set path ""
foreach f [list $base.$lang.$ext $base.$ext] {
set p $conf(static-dir)/$f
set p $conf(files)/$f
if {[file exists $p]} then {
set path $p
break
......
......@@ -2,13 +2,13 @@
# worker program (worker thread to answer SCGI requests)
#
# Tcl variables initialized during the thread start
# - conffile: pathname of configuration file
# - wrkdir: pathname of the directory containing this file
# - conf(conffile): pathname of configuration file
# - conf(libdir): pathname of the directory containing worker/ and pkgtcl/
# - conf(files): pathname of the directory containing *.html files
# - conf(version): application version
# - auto_path: path of Tcl packages specific to Netmagis
#
set conf(static-dir) %NMLIBDIR%/www
set conf(static-dir) /tmp
set conf(lang) {en fr}
package require snit
......@@ -32,12 +32,14 @@ array set route {
# Thread initialisation
##############################################################################
proc thread-init {conffile wdir} {
proc thread-init {conffile version wdir} {
global conf
::lconf::lconf create ::lc
::lc read $conffile
::pgdb::db create ::dbdns
::dbdns init "dns" ::lc 3.0.0foobar ;# "%NMVERSION%"
::dbdns init "dns" ::lc $version
::pgdb::db create ::dbmac
::dbmac init "mac" ::lc ""
......@@ -612,11 +614,13 @@ proc api-handler {method pathspec authneeded paramspec script} {
# - stdout: <code> <text>
proc handle-request {uri meth parm cookie} {
global wrkdir
global conf
global route
set msgdir conf(libdir)/worker/msgs
uplevel #0 mclocale "en"
uplevel #0 mcload $wrkdir/msgs
uplevel #0 mcload $msgdir
set ok 0
foreach r $route($meth) {
......@@ -683,7 +687,7 @@ proc handle-request {uri meth parm cookie} {
if {$l ne ""} then {
uplevel #0 mclocale $l
uplevel #0 mcload $wrkdir/msgs
uplevel #0 mcload $msgdir
}
#
......@@ -744,7 +748,7 @@ proc check-route {uri parm re vars paramspec} {
}
try {
thread-init $conffile $wrkdir
thread-init $conf(conffile) $conf(version) $conf(libdir)/worker
} on error msg {
puts stderr $msg
exit 1
......
......@@ -2,16 +2,16 @@ NINSTALL = ../ninstall
build:
@echo ">>> Making build in `pwd`"
cd lib ; make build
cd src ; make build
cd lib ; $(MAKE) build
cd src ; $(MAKE) build
install: build
@echo ">>> Making install in `pwd`"
cd src ; make $(DIRS) install
cd eqvirt ; make $(DIRS) install
cd src ; $(MAKE) install
cd eqvirt ; $(MAKE) install
mkdir -p $(DESTDIR)$(NMVARDIR)/eqvirt
mkdir -p $(DESTDIR)$(NMVARDIR)/eqgen
clean:
cd lib ; make clean
cd src ; make clean
cd lib ; $(MAKE) clean
cd src ; $(MAKE) clean
......@@ -2,7 +2,7 @@ NINSTALL = ../ninstall
build:
@echo ">>> Making build in `pwd`"
cd htg ; make TCLCFLAGS="$(TCLCFLAGS)" TCLLFLAGS="$(TCLLFLAGS)" build
cd htg ; $(MAKE) TCLCFLAGS="$(TCLCFLAGS)" TCLLFLAGS="$(TCLLFLAGS)" build
install: build
@echo ">>> Making install in `pwd`"
......@@ -10,12 +10,12 @@ install: build
# install CGI
#
mkdir -p $(DESTDIR)$(NMCGIDIR)
cd cgi ; make $(DIRS) install
cd cgi ; $(MAKE) install
#
# install API
#
mkdir -p $(DESTDIR)$(NMCGIDIR)
cd nmd ; make $(DIRS) install
cd nmd ; $(MAKE) install
############################## WARNING : REMOVE AS SOON AS POSSIBLE
exit 1
......@@ -29,7 +29,7 @@ install: build
#
# install htg and models
#
cd htg ; make $(DIRS) install
cd htg ; $(MAKE) install
#
# install tmpl pages
#
......@@ -46,7 +46,7 @@ install: build
#
# install default files
#
cd share ; make $(DIRS) install
cd share ; $(MAKE) install
clean:
cd htg ; make clean
cd htg ; $(MAKE) clean
......@@ -5,14 +5,14 @@ TCLLFLAGS = -L/usr/local/lib -ltcl85 -lm
build:
@echo ">>> Making build in `pwd`"
cd src ; make TCLCFLAGS="$(TCLCFLAGS)" TCLLFLAGS="$(TCLLFLAGS)" build
cd src ; $(MAKE) TCLCFLAGS="$(TCLCFLAGS)" TCLLFLAGS="$(TCLLFLAGS)" build
install: build
@echo ">>> Making install in `pwd`"
mkdir -p $(DESTDIR)$(BINDIR)
cd src ; make $(DIRS) install
cd src ; $(MAKE) install
mkdir -p $(DESTDIR)$(NMLIBDIR)/htg
tar cf - models doc | tar xf - -C $(DESTDIR)$(NMLIBDIR)/htg
clean:
cd src ; make clean
cd src ; $(MAKE) clean
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment