Skip to content

Commit

Permalink
Build the POSIX binding using mmc --make.
Browse files Browse the repository at this point in the history
Building the POSIX binding using mmc --make by default and just have mmake
forward its work to that.  Using mmc --make means things like library grade
exclusions will work properly.

Exclude non-C grades from the grade set in which to install the POSIX binding.

Shift a POSIX binding sample into the samples subdirectory.

extras/posix/Makefile:
extras/posix/Mercury.options:
    Build the POSIX binding using mmc --make.

extras/posix/Mmakefile:
    Redirect mmake to use the normal Makefile.

extras/posix/hello.m:
    Shift this file into the samples subdirectory.

extras/samples/Makefile:
    Set up things to build the samples against a libposix in the
    parent directory.

extras/samples/Mmakefile:
    Delete this file.
  • Loading branch information
juliensf committed Mar 21, 2019
1 parent 1338dce commit dcf7945
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 59 deletions.
29 changes: 29 additions & 0 deletions extras/posix/Makefile
@@ -0,0 +1,29 @@
#-----------------------------------------------------------------------------#
# vim: ts=8 sw=8 noexpandtab
#-----------------------------------------------------------------------------#
# Copyright (C) 2011 The University of Melbourne.
# Copyright (C) 2015, 2018-2019 The Mercury team.
# This file is distributed under the terms specified in COPYING.LIB.
#-----------------------------------------------------------------------------#

# Build the posix library using mmc --make.

TARGET = posix
MMC = mmc

.PHONY: build
build: posix_workarounds.o
$(MMC) --make lib$(TARGET)

.PHONY: install
install: posix_workarounds.o
$(MMC) --make lib$(TARGET).install

posix_workarounds.o: posix_workarounds.c

.PHONY: realclean
realclean:
cd samples && $(MAKE) realclean
$(MMC) --make $(TARGET).realclean
/bin/rm -f posix_workarounds.o
/bin/rm -rf Mercury
6 changes: 6 additions & 0 deletions extras/posix/Mercury.options
@@ -0,0 +1,6 @@
MCFLAGS = \
--libgrades-exclude java \
--libgrades-exclude csharp \
--libgrades-exclude erlang \
--link-object posix_workarounds.o \
--extra-library-header posix_workarounds.h
47 changes: 16 additions & 31 deletions extras/posix/Mmakefile
Expand Up @@ -6,42 +6,27 @@
# This file is distributed under the terms specified in COPYING.LIB.
#-----------------------------------------------------------------------------#

INSTALL_PREFIX := $(INSTALL_PREFIX)/extras
# This is file exists so that do an `mmake' from the top-level of the extras
# distribution works. The actual work of building this library is done
# using the Makefile and mmc --make. This file just forwards all the work
# to there.

-include ../Mmake.params
MAIN_TARGET=build

# The following is needed (on some systems) to enable declarations of
# Posix functions in standard C header files.
MGNUCFLAGS = --no-ansi

# This library has some parts that are implemented in C
# rather than in Mercury. The following lines ensure that
# the .h and .o files for those parts get included in the library.
ADDITIONAL_HDRS = posix_workarounds.h
MLOBJS = posix_workarounds.$O
MLPICOBJS = posix_workarounds.$(EXT_FOR_PIC_OBJECTS)

.PHONY: default_target
default_target: all
.PHONY: build
build:
$(MAKE) build

# The depend target does nothing, mmc --make will handle dependencies
# automatically.
#
.PHONY: depend
depend: posix.depend hello.depend

.PHONY: all
all: libposix hello

.PHONY: check
check: hello
./hello
depend:

.PHONY: install
install: libposix.install
cp $(ADDITIONAL_HDRS) $(INSTALL_PREFIX)/lib/mercury/inc

.PHONY: clean
clean:
-/bin/rm -f posix_workarounds.$(O)
-/bin/rm -f posix_workarounds.$(EXT_FOR_PIC_OBJECTS)
install:
$(MAKE) install INSTALL_PREFIX=$(INSTALL_PREFIX)/extras

.PHONY: realclean
realclean: clean
realclean:
$(MAKE) realclean
16 changes: 16 additions & 0 deletions extras/posix/samples/Makefile
@@ -0,0 +1,16 @@
DEMOS = mdprof_cgid hello
MMC = mmc

# The following target builds the demos and links them against the posix
# library in the parent directory in situ.
#
all:
$(MMC) --search-lib-files-dir .. \
--init-file ../posix.init \
--link-object ../libposix.a \
--make $(DEMOS)

.PHONY: realclean
realclean:
$(MMC) --make $(DEMOS:%=%.realclean)
/bin/rm -rf Mercury
28 changes: 0 additions & 28 deletions extras/posix/samples/Mmakefile

This file was deleted.

File renamed without changes.

0 comments on commit dcf7945

Please sign in to comment.