]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Remove support for building with BSD Make.
authorPeter Powell <petpow@saberuk.com>
Wed, 12 Jul 2017 12:08:28 +0000 (13:08 +0100)
committerPeter Powell <petpow@saberuk.com>
Mon, 24 Jul 2017 16:00:05 +0000 (17:00 +0100)
BSD users should install GNU Make to build InspIRCd.

.gitignore
make/configure.pm
make/template/bsd.mk [new file with mode: 0644]
make/template/main.mk

index 3aea64f531cad703c97f8ba558af22179aae03eb..e9d91b29bee6a7d3224c55b714c7b74f85b3752f 100644 (file)
@@ -6,7 +6,7 @@
 !.git*
 
 /.configure
-/BSDmakefile
+/Makefile
 /GNUmakefile
 /build
 /docs/doxygen
index dbbbf650978ec6af386201428b34594c221adafd..dfdbf5f75d680b7ab8e0669b154b8fd60849f588 100644 (file)
@@ -258,7 +258,7 @@ sub parse_templates($$$) {
        foreach (<make/template/*>) {
                print_format "Parsing <|GREEN $_|> ...\n";
                open(my $fh, $_) or print_error "unable to read $_: $!";
-               my (@lines, $mode, @platforms, %targets);
+               my (@lines, $mode, @platforms, @targets);
 
                # First pass: parse template variables and directives.
                while (my $line = <$fh>) {
@@ -288,11 +288,7 @@ sub parse_templates($$$) {
                                } elsif ($1 eq 'platform') {
                                        push @platforms, $2;
                                } elsif ($1 eq 'target') {
-                                       if ($2 =~ /(\w+)\s(.+)/) {
-                                               $targets{$1} = $2;
-                                       } else {
-                                               $targets{DEFAULT} = $2;
-                                       }
+                                       push @targets, $2
                                } else {
                                        print_warning "unknown template command '$1' in $_!";
                                        push @lines, $line;
@@ -307,86 +303,12 @@ sub parse_templates($$$) {
                if ($#platforms < 0 || grep { $_ eq $^O } @platforms) {
 
                        # Add a default target if the template has not defined one.
-                       unless (scalar keys %targets) {
-                               $targets{DEFAULT} = catfile(CONFIGURE_DIRECTORY, basename $_);
+                       unless (@targets) {
+                               push @targets, catfile(CONFIGURE_DIRECTORY, basename $_);
                        }
 
-                       # Second pass: parse makefile junk and write files.
-                       while (my ($name, $target) = each %targets) {
-
-                               # TODO: when buildtool is done this mess can be removed completely.
-                               my @final_lines;
-                               foreach my $line (@lines) {
-
-                                       # Are we parsing a makefile and does this line match a statement?
-                                       if ($name =~ /(?:BSD|GNU)_MAKE/ && $line =~ /^\s*\@(\w+)(?:\s+(.+))?$/) {
-                                               my @tokens = split /\s/, $2 if defined $2;
-                                               if ($1 eq 'DO_EXPORT' && defined $2) {
-                                                       if ($name eq 'BSD_MAKE') {
-                                                               foreach my $variable (@tokens) {
-                                                                       push @final_lines, "MAKEENV += $variable='\${$variable}'";
-                                                               }
-                                                       } elsif ($name eq 'GNU_MAKE') {
-                                                               push @final_lines, "export $2";
-                                                       }
-                                               } elsif ($1 eq 'ELSE') {
-                                                       if ($name eq 'BSD_MAKE') {
-                                                               push @final_lines, ".else";
-                                                       } elsif ($name eq 'GNU_MAKE') {
-                                                               push @final_lines, "else";
-                                                       }
-                                               } elsif ($1 eq 'ENDIF') {
-                                                       if ($name eq 'BSD_MAKE') {
-                                                               push @final_lines, ".endif";
-                                                       } elsif ($name eq 'GNU_MAKE') {
-                                                               push @final_lines, "endif";
-                                                       }
-                                               } elsif ($1 eq 'ELSIFEQ' && defined $2) {
-                                                       if ($name eq 'BSD_MAKE') {
-                                                               push @final_lines, ".elif $tokens[0] == $tokens[1]";
-                                                       } elsif ($name eq 'GNU_MAKE') {
-                                                               push @final_lines, "else ifeq ($tokens[0], $tokens[1])";
-                                                       }
-                                               } elsif ($1 eq 'IFDEF' && defined $2) {
-                                                       if ($name eq 'BSD_MAKE') {
-                                                               push @final_lines, ".if defined($2)";
-                                                       } elsif ($name eq 'GNU_MAKE') {
-                                                               push @final_lines, "ifdef $2";
-                                                       }
-                                               } elsif ($1 eq 'IFEQ' && defined $2) {
-                                                       if ($name eq 'BSD_MAKE') {
-                                                               push @final_lines, ".if $tokens[0] == $tokens[1]";
-                                                       } elsif ($name eq 'GNU_MAKE') {
-                                                               push @final_lines, "ifeq ($tokens[0],$tokens[1])";
-                                                       }
-                                               } elsif ($1 eq 'IFNEQ' && defined $2) {
-                                                       if ($name eq 'BSD_MAKE') {
-                                                               push @final_lines, ".if $tokens[0] != $tokens[1]";
-                                                       } elsif ($name eq 'GNU_MAKE') {
-                                                               push @final_lines, "ifneq ($tokens[0],$tokens[1])";
-                                                       }
-                                               } elsif ($1 eq 'IFNDEF' && defined $2) {
-                                                       if ($name eq 'BSD_MAKE') {
-                                                               push @final_lines, ".if !defined($2)";
-                                                       } elsif ($name eq 'GNU_MAKE') {
-                                                               push @final_lines, "ifndef $2";
-                                                       }
-                                               } elsif ($1 eq 'TARGET' && defined $2) {
-                                                       if ($tokens[0] eq $name) {
-                                                               push @final_lines, substr($2, length($tokens[0]) + 1);
-                                                       }
-                                               } elsif ($1 !~ /[A-Z]/) {
-                                                       # HACK: silently ignore if lower case as these are probably make commands.
-                                                       push @final_lines, $line;
-                                               } else {
-                                                       print_warning "unknown template command '$1' in $_!";
-                                                       push @final_lines, $line;
-                                               }
-                                               next;
-                                       }
-
-                                       push @final_lines, $line;
-                               }
+                       # Write the templated files to disk.
+                       for my $target (@targets) {
 
                                # Create the directory if it doesn't already exist.
                                my $directory = dirname $target;
@@ -398,7 +320,7 @@ sub parse_templates($$$) {
                                # Write the template file.
                                print_format "Writing <|GREEN $target|> ...\n";
                                open(my $fh, '>', $target) or print_error "unable to write $target: $!";
-                               foreach (@final_lines) {
+                               foreach (@lines) {
                                        say $fh $_;
                                }
                                close $fh;
diff --git a/make/template/bsd.mk b/make/template/bsd.mk
new file mode 100644 (file)
index 0000000..05d413d
--- /dev/null
@@ -0,0 +1,33 @@
+%platform darwin
+%platform freebsd
+%platform netbsd
+%platform openbsd
+%target Makefile
+#
+# InspIRCd -- Internet Relay Chat Daemon
+#
+#   Copyright (C) 2017 Peter Powell <petpow@saberuk.com>
+#
+# This file is part of InspIRCd.  InspIRCd is free software: you can
+# redistribute it and/or modify it under the terms of the GNU General Public
+# License as published by the Free Software Foundation, version 2.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+# details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+
+# This file will be installed as `Makefile` on BSD derivatives. When a user runs
+# BSD Make it will be picked up as the default makefile even on systems like
+# OpenBSD which have removed BSDMakefile support. If they run GNU Make then it
+# will ignore this file and run GNUmakefile instead.
+
+all clean configureclean debug deinstall distclean help install:
+       @echo "InspIRCd no longer supports BSD Make. You should install GNU Make instead."
+       @echo "If this is problematic for you then please contact us via our IRC channel"
+       @echo "at irc.inspircd.org #InspIRCd."
+       @exit 1
index 50feb8f8d01ab505aa87d43cc031eab952d94d4b..49c77da0555f53a2710dfbe7385ab2367e0fd24b 100644 (file)
@@ -1,5 +1,4 @@
-%target BSD_MAKE BSDmakefile
-%target GNU_MAKE GNUmakefile
+%target GNUmakefile
 #
 # InspIRCd -- Internet Relay Chat Daemon
 #
@@ -26,9 +25,7 @@
 # make/template/main.mk. Any changes made to the generated
 #     files will go away whenever it is regenerated!
 #
-# Please do not edit unless you know what you're doing. This
-# needs to work in both GNU and BSD make; it is mangled for
-# them by configure.
+# Please do not edit unless you know what you're doing.
 #
 
 
@@ -54,101 +51,106 @@ INSTMODE_DIR = 0750
 INSTMODE_BIN = 0750
 INSTMODE_LIB = 0640
 
-@IFNEQ $(COMPILER) ICC
+ifneq ($(COMPILER), ICC)
   CORECXXFLAGS += -Woverloaded-virtual -Wshadow
-@IFNEQ $(SYSTEM) openbsd
+ifneq ($(SYSTEM), openbsd)
     CORECXXFLAGS += -pedantic -Wformat=2 -Wmissing-format-attribute
-@ENDIF
-@ENDIF
+endif
+endif
 
-@IFNEQ $(SYSTEM) darwin
+ifneq ($(SYSTEM), darwin)
   LDLIBS += -pthread
-@ENDIF
+endif
 
-@IFEQ $(SYSTEM) linux
+ifeq ($(SYSTEM), linux)
   LDLIBS += -ldl -lrt
-@ENDIF
-@IFEQ $(SYSTEM) gnukfreebsd
+endif
+ifeq ($(SYSTEM), gnukfreebsd)
   LDLIBS += -ldl -lrt
-@ENDIF
-@IFEQ $(SYSTEM) gnu
+endif
+ifeq ($(SYSTEM), gnu)
   LDLIBS += -ldl -lrt
-@ENDIF
-@IFEQ $(SYSTEM) solaris
+endif
+ifeq ($(SYSTEM), solaris)
   LDLIBS += -lsocket -lnsl -lrt -lresolv
   INSTALL = ginstall
-@ENDIF
-@IFEQ $(SYSTEM) darwin
+endif
+ifeq ($(SYSTEM), darwin)
   LDLIBS += -ldl
   CORELDFLAGS = -dynamic -bind_at_load -L. $(LDFLAGS)
   PICLDFLAGS = -fPIC -shared -twolevel_namespace -undefined dynamic_lookup $(LDFLAGS)
-@ENDIF
+endif
 
-@IFNDEF INSPIRCD_DEBUG
+ifndef INSPIRCD_DEBUG
   INSPIRCD_DEBUG=0
-@ENDIF
+endif
 
 DBGOK=0
-@IFEQ $(INSPIRCD_DEBUG) 0
+ifeq ($(INSPIRCD_DEBUG), 0)
   CORECXXFLAGS += -fno-rtti -O2
-@IFEQ $(COMPILER) GCC
+ifeq ($(COMPILER), GCC)
     CORECXXFLAGS += -g1
-@ENDIF
+endif
   HEADER = std-header
   DBGOK=1
-@ENDIF
-@IFEQ $(INSPIRCD_DEBUG) 1
+endif
+ifeq ($(INSPIRCD_DEBUG), 1)
   CORECXXFLAGS += -O0 -g3 -Werror -DINSPIRCD_ENABLE_RTTI
   HEADER = debug-header
   DBGOK=1
-@ENDIF
-@IFEQ $(INSPIRCD_DEBUG) 2
+endif
+ifeq ($(INSPIRCD_DEBUG), 2)
   CORECXXFLAGS += -fno-rtti -O2 -g3
   HEADER = debug-header
   DBGOK=1
-@ENDIF
+endif
 FOOTER = finishmessage
 
-@TARGET GNU_MAKE MAKEFLAGS += --no-print-directory
+MAKEFLAGS += --no-print-directory
 
-@TARGET GNU_MAKE SOURCEPATH = $(shell /bin/pwd)
-@TARGET BSD_MAKE SOURCEPATH != /bin/pwd
+SOURCEPATH = $(shell /bin/pwd)
 
-@IFNDEF INSPIRCD_VERBOSE
-  @TARGET GNU_MAKE MAKEFLAGS += --silent
-  @TARGET BSD_MAKE MAKE += -s
-@ENDIF
+ifndef INSPIRCD_VERBOSE
+  MAKEFLAGS += --silent
+endif
 
-@IFDEF INSPIRCD_STATIC
+ifdef INSPIRCD_STATIC
   CORECXXFLAGS += -DINSPIRCD_STATIC
-@ENDIF
+endif
 
 # Add the users CPPFLAGS/CXXFLAGS to the base ones to allow them to
 # override things like -Wfatal-errors if they wish to.
 CORECXXFLAGS += $(CPPFLAGS) $(CXXFLAGS)
 
-@DO_EXPORT CXX CORECXXFLAGS LDLIBS PICLDFLAGS INSPIRCD_VERBOSE SOCKETENGINE CORELDFLAGS
-@DO_EXPORT SOURCEPATH BUILDPATH INSPIRCD_STATIC
+export BUILDPATH
+export CORECXXFLAGS
+export CORELDFLAGS
+export CXX
+export INSPIRCD_STATIC
+export INSPIRCD_VERBOSE
+export LDLIBS
+export PICLDFLAGS
+export SOCKETENGINE
+export SOURCEPATH
 
 # Default target
 TARGET = all
 
-@IFDEF INSPIRCD_MODULE
+ifdef INSPIRCD_MODULE
     HEADER = mod-header
     FOOTER = mod-footer
-    @TARGET BSD_MAKE TARGET = modules/${INSPIRCD_MODULE:S/.so$//}.so
-    @TARGET GNU_MAKE TARGET = modules/$(INSPIRCD_MODULE:.so=).so
-@ENDIF
+    TARGET = modules/$(INSPIRCD_MODULE:.so=).so
+endif
 
-@IFDEF INSPIRCD_TARGET
+ifdef INSPIRCD_TARGET
     HEADER =
     FOOTER = target
     TARGET = $(INSPIRCD_TARGET)
-@ENDIF
+endif
 
-@IFEQ $(DBGOK) 0
+ifeq ($(DBGOK), 0)
   HEADER = unknown-debug-level
-@ENDIF
+endif
 
 all: $(FOOTER)
 
@@ -174,10 +176,10 @@ debug-header:
        @echo "*************************************"
 
 mod-header:
-@IFDEF INSPIRCD_STATIC
+ifdef INSPIRCD_STATIC
        @echo 'Cannot build single modules in pure-static build'
        @exit 1
-@ENDIF
+endif
        @echo 'Building single module:'
 
 mod-footer: target
@@ -223,17 +225,17 @@ install: target
        @-$(INSTALL) -d -m $(INSTMODE_DIR) $(MANPATH)
        @-$(INSTALL) -d -m $(INSTMODE_DIR) $(MODPATH)
        [ "$(BUILDPATH)/bin/" -ef $(BINPATH) ] || $(INSTALL) -m $(INSTMODE_BIN) "$(BUILDPATH)/bin/inspircd" $(BINPATH)
-@IFNDEF INSPIRCD_STATIC
+ifndef INSPIRCD_STATIC
        [ "$(BUILDPATH)/modules/" -ef $(MODPATH) ] || $(INSTALL) -m $(INSTMODE_LIB) "$(BUILDPATH)/modules/"*.so $(MODPATH)
-@ENDIF
+endif
        -$(INSTALL) -m $(INSTMODE_BIN) @CONFIGURE_DIRECTORY@/inspircd $(BASE) 2>/dev/null
        -$(INSTALL) -m $(INSTMODE_LIB) .gdbargs $(BASE)/.gdbargs 2>/dev/null
-@IFEQ $(SYSTEM) darwin
+ifeq ($(SYSTEM), darwin)
        -$(INSTALL) -m $(INSTMODE_BIN) @CONFIGURE_DIRECTORY@/org.inspircd.plist $(BASE) 2>/dev/null
-@ENDIF
-@IFEQ $(SYSTEM) linux
+endif
+ifeq ($(SYSTEM), linux)
        -$(INSTALL) -m $(INSTMODE_LIB) @CONFIGURE_DIRECTORY@/inspircd.service $(BASE) 2>/dev/null
-@ENDIF
+endif
        -$(INSTALL) -m $(INSTMODE_LIB) @CONFIGURE_DIRECTORY@/inspircd.1 $(MANPATH) 2>/dev/null
        -$(INSTALL) -m $(INSTMODE_LIB) @CONFIGURE_DIRECTORY@/inspircd-genssl.1 $(MANPATH) 2>/dev/null
        -$(INSTALL) -m $(INSTMODE_BIN) tools/genssl $(BINPATH)/inspircd-genssl 2>/dev/null
@@ -255,9 +257,8 @@ install: target
        @echo 'Remember to create your config file:' $(CONPATH)/inspircd.conf
        @echo 'Examples are available at:' $(CONPATH)/examples/
 
-GNUmakefile BSDmakefile: make/template/main.mk src/version.sh configure @CONFIGURE_CACHE_FILE@
+GNUmakefile: make/template/main.mk src/version.sh configure @CONFIGURE_CACHE_FILE@
        ./configure --update
-@TARGET BSD_MAKE .MAKEFILEDEPS: BSDmakefile
 
 clean:
        @echo Cleaning...
@@ -280,7 +281,7 @@ deinstall:
 
 configureclean:
        rm -f .gdbargs
-       rm -f BSDmakefile
+       -rm -f Makefile
        rm -f GNUmakefile
        rm -f include/config.h
        rm -rf @CONFIGURE_DIRECTORY@