I'm trying to build GLEW. But the following happens:
C:\Users\User\Desktop\glew-1.11.0>dir
Volume in drive C is Windows7_OS
Volume Serial Number is B0CB-4CEE
Directory of C:\Users\User\Desktop\glew-1.11.0
13-12-2014 23:45 <DIR> .
13-12-2014 23:45 <DIR> ..
13-12-2014 23:44 <DIR> auto
11-08-2014 15:14 <DIR> bin
13-12-2014 22:48 <DIR> build
13-12-2014 22:48 <DIR> config
13-12-2014 22:48 <DIR> doc
11-08-2014 15:14 276 glew.pc.in
13-12-2014 22:48 <DIR> include
11-08-2014 15:14 <DIR> lib
11-08-2014 15:14 3.870 LICENSE.txt
14-12-2014 00:26 13.932 Makefile
11-08-2014 15:14 591 README.txt
13-12-2014 22:48 <DIR> src
13-12-2014 23:45 <DIR> tmp
11-08-2014 15:14 428 TODO.txt
5 File(s) 19.097 bytes
11 Dir(s) 339.881.320.448 bytes free
C:\Users\User\Desktop\glew-1.11.0>make
cc -DGLEW_NO_GLU -O2 -Wall -W -Iinclude -o tmp/cygwin/default/shared/glew.o -c src/glew.c
make: cc: Command not found
Makefile:127: recipe for target 'tmp/cygwin/default/shared/glew.o' failed
make: *** [tmp/cygwin/default/shared/glew.o] Error 127
C:\Users\User\Desktop\glew-1.11.0>which gcc
/cygdrive/c/MinGW/bin/gcc
C:\Users\User\Desktop\glew-1.11.0>gcc --version
gcc (i686-win32-dwarf-rev0, Built by MinGW-W64 project) 4.9.2
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
As you can see gcc is installed. the C:\MinGW\bin folder where it's located is also in my PATH variable.
Here's the content of the Makefile:
#!gmake
## The OpenGL Extension Wrangler Library
## Copyright (C) 2002-2008, Milan Ikits <milan ikits[]ieee org>
## Copyright (C) 2002-2008, Marcelo E. Magallon <mmagallo[]debian org>
## Copyright (C) 2002, Lev Povalahev
## All rights reserved.
##
## Redistribution and use in source and binary forms, with or without
## modification, are permitted provided that the following conditions are met:
##
## * Redistributions of source code must retain the above copyright notice,
## this list of conditions and the following disclaimer.
## * Redistributions in binary form must reproduce the above copyright notice,
## this list of conditions and the following disclaimer in the documentation
## and/or other materials provided with the distribution.
## * The name of the author may be used to endorse or promote products
## derived from this software without specific prior written permission.
##
## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
## AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
## ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
## LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
## CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
## SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
## INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
## CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
## ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
## THE POSSIBILITY OF SUCH DAMAGE.
include config/version
SHELL = /bin/sh
SYSTEM ?= $(shell config/config.guess | cut -d - -f 3 | sed -e 's/[0-9\.]//g;')
SYSTEM.SUPPORTED = $(shell test -f config/Makefile.$(SYSTEM) && echo 1)
ifeq ($(SYSTEM.SUPPORTED), 1)
include config/Makefile.$(SYSTEM)
else
$(error "Platform '$(SYSTEM)' not supported")
endif
GLEW_PREFIX ?= /usr
GLEW_DEST ?= /usr
BINDIR ?= $(GLEW_DEST)/bin
LIBDIR ?= $(GLEW_DEST)/lib
INCDIR ?= $(GLEW_DEST)/include/GL
ifneq ($(GLEW_NO_GLU), -DGLEW_NO_GLU)
LIBGLU = glu
endif
DIST_NAME ?= glew-$(GLEW_VERSION)
DIST_SRC_ZIP ?= $(shell pwd)/$(DIST_NAME).zip
DIST_SRC_TGZ ?= $(shell pwd)/$(DIST_NAME).tgz
DIST_WIN32 ?= $(shell pwd)/$(DIST_NAME)-win32.zip
DIST_DIR := $(shell mktemp -d /tmp/glew.XXXXXX)/$(DIST_NAME)
# To disable stripping of binaries either:
# - use STRIP= on gmake command-line
# - edit this makefile to set STRIP to the empty string
#
# To disable symlinks:
# - use LN= on gmake command-line
AR ?= ar
INSTALL ?= install
STRIP ?= strip
RM ?= rm -f
LN ?= ln -sf
ifneq (,$(filter debug,$(MAKECMDGOALS)))
OPT = -g
else
OPT = $(POPT)
endif
INCLUDE = -Iinclude
CFLAGS = $(OPT) $(WARN) $(INCLUDE) $(CFLAGS.EXTRA)
all debug: glew.lib glew.lib.mx glew.bin
# GLEW shared and static libraries
LIB.LDFLAGS := $(LDFLAGS.EXTRA) $(LDFLAGS.GL)
LIB.LIBS := $(GL_LDFLAGS)
LIB.SRCS := src/glew.c
LIB.SRCS.NAMES := $(notdir $(LIB.SRCS))
LIB.OBJS := $(addprefix tmp/$(SYSTEM)/default/static/,$(LIB.SRCS.NAMES))
LIB.OBJS := $(LIB.OBJS:.c=.o)
LIB.SOBJS := $(addprefix tmp/$(SYSTEM)/default/shared/,$(LIB.SRCS.NAMES))
LIB.SOBJS := $(LIB.SOBJS:.c=.o)
LIB.OBJS.MX := $(addprefix tmp/$(SYSTEM)/mx/static/,$(LIB.SRCS.NAMES))
LIB.OBJS.MX := $(LIB.OBJS.MX:.c=.o)
LIB.SOBJS.MX := $(addprefix tmp/$(SYSTEM)/mx/shared/,$(LIB.SRCS.NAMES))
LIB.SOBJS.MX := $(LIB.SOBJS.MX:.c=.o)
glew.lib: lib lib/$(LIB.SHARED) lib/$(LIB.STATIC) glew.pc
lib:
mkdir lib
lib/$(LIB.STATIC): $(LIB.OBJS)
$(AR) cr $# $^
ifneq ($(STRIP),)
$(STRIP) -x $#
endif
lib/$(LIB.SHARED): $(LIB.SOBJS)
$(LD) $(LDFLAGS.SO) -o $# $^ $(LIB.LDFLAGS) $(LIB.LIBS)
ifneq ($(LN),)
$(LN) $(LIB.SHARED) lib/$(LIB.SONAME)
$(LN) $(LIB.SHARED) lib/$(LIB.DEVLNK)
endif
ifneq ($(STRIP),)
$(STRIP) -x $#
endif
tmp/$(SYSTEM)/default/static/glew.o: src/glew.c include/GL/glew.h include/GL/wglew.h include/GL/glxew.h
#mkdir -p $(dir $#)
$(CC) -DGLEW_NO_GLU -DGLEW_STATIC $(CFLAGS) $(CFLAGS.SO) -o $# -c $<
tmp/$(SYSTEM)/default/shared/glew.o: src/glew.c include/GL/glew.h include/GL/wglew.h include/GL/glxew.h
#mkdir -p $(dir $#)
$(CC) -DGLEW_NO_GLU $(CFLAGS) $(CFLAGS.SO) -o $# -c $<
# Force re-write of glew.pc, GLEW_DEST can vary
.PHONY: glew.pc
glew.pc: glew.pc.in
sed \
-e "s|#prefix#|$(GLEW_PREFIX)|g" \
-e "s|#libdir#|$(LIBDIR)|g" \
-e "s|#exec_prefix#|$(BINDIR)|g" \
-e "s|#includedir#|$(INCDIR)|g" \
-e "s|#version#|$(GLEW_VERSION)|g" \
-e "s|#cflags#||g" \
-e "s|#libname#|$(NAME)|g" \
-e "s|#requireslib#|$(LIBGLU)|g" \
< $< > $#
# GLEW MX static and shared libraries
glew.lib.mx: lib lib/$(LIB.SHARED.MX) lib/$(LIB.STATIC.MX) glewmx.pc
lib/$(LIB.STATIC.MX): $(LIB.OBJS.MX)
$(AR) cr $# $^
lib/$(LIB.SHARED.MX): $(LIB.SOBJS.MX)
$(LD) $(LDFLAGS.SO.MX) -o $# $^ $(LIB.LDFLAGS) $(LIB.LIBS)
ifneq ($(LN),)
$(LN) $(LIB.SHARED.MX) lib/$(LIB.SONAME.MX)
$(LN) $(LIB.SHARED.MX) lib/$(LIB.DEVLNK.MX)
endif
ifneq ($(STRIP),)
$(STRIP) -x $#
endif
tmp/$(SYSTEM)/mx/static/glew.o: src/glew.c include/GL/glew.h include/GL/wglew.h include/GL/glxew.h
#mkdir -p $(dir $#)
$(CC) -DGLEW_NO_GLU -DGLEW_MX -DGLEW_STATIC $(CFLAGS) $(CFLAGS.SO) -o $# -c $<
tmp/$(SYSTEM)/mx/shared/glew.o: src/glew.c include/GL/glew.h include/GL/wglew.h include/GL/glxew.h
#mkdir -p $(dir $#)
$(CC) -DGLEW_NO_GLU -DGLEW_MX $(CFLAGS) $(CFLAGS.SO) -o $# -c $<
# Force re-write of glewmx.pc, GLEW_DEST can vary
.PHONY: glewmx.pc
glewmx.pc: glew.pc.in
sed \
-e "s|#prefix#|$(GLEW_PREFIX)|g" \
-e "s|#libdir#|$(LIBDIR)|g" \
-e "s|#exec_prefix#|$(BINDIR)|g" \
-e "s|#includedir#|$(INCDIR)|g" \
-e "s|#version#|$(GLEW_VERSION)|g" \
-e "s|#cflags#|-DGLEW_MX|g" \
-e "s|#libname#|$(NAME)mx|g" \
-e "s|#requireslib#|$(LIBGLU)|g" \
< $< > $#
# GLEW utility programs
BIN.LIBS = -Llib $(LDFLAGS.DYNAMIC) -l$(NAME) $(LDFLAGS.EXTRA) $(LDFLAGS.GL)
GLEWINFO.BIN := glewinfo$(BIN.SUFFIX)
GLEWINFO.BIN.SRC := src/glewinfo.c
GLEWINFO.BIN.OBJ := $(addprefix tmp/$(SYSTEM)/default/shared/,$(notdir $(GLEWINFO.BIN.SRC)))
GLEWINFO.BIN.OBJ := $(GLEWINFO.BIN.OBJ:.c=.o)
VISUALINFO.BIN := visualinfo$(BIN.SUFFIX)
VISUALINFO.BIN.SRC := src/visualinfo.c
VISUALINFO.BIN.OBJ := $(addprefix tmp/$(SYSTEM)/default/shared/,$(notdir $(VISUALINFO.BIN.SRC)))
VISUALINFO.BIN.OBJ := $(VISUALINFO.BIN.OBJ:.c=.o)
# Don't build glewinfo or visualinfo for NaCL, yet.
ifneq ($(filter nacl%,$(SYSTEM)),)
glew.bin: glew.lib bin
else
glew.bin: glew.lib bin bin/$(GLEWINFO.BIN) bin/$(VISUALINFO.BIN)
endif
bin:
mkdir bin
bin/$(GLEWINFO.BIN): $(GLEWINFO.BIN.OBJ) lib/$(LIB.SHARED)
$(CC) $(CFLAGS) -o $# $(GLEWINFO.BIN.OBJ) $(BIN.LIBS)
ifneq ($(STRIP),)
$(STRIP) -x $#
endif
bin/$(VISUALINFO.BIN): $(VISUALINFO.BIN.OBJ) lib/$(LIB.SHARED)
$(CC) $(CFLAGS) -o $# $(VISUALINFO.BIN.OBJ) $(BIN.LIBS)
ifneq ($(STRIP),)
$(STRIP) -x $#
endif
$(GLEWINFO.BIN.OBJ): $(GLEWINFO.BIN.SRC) include/GL/glew.h include/GL/wglew.h include/GL/glxew.h
#mkdir -p $(dir $#)
$(CC) -DGLEW_NO_GLU $(CFLAGS) $(CFLAGS.SO) -o $# -c $<
$(VISUALINFO.BIN.OBJ): $(VISUALINFO.BIN.SRC) include/GL/glew.h include/GL/wglew.h include/GL/glxew.h
#mkdir -p $(dir $#)
$(CC) -DGLEW_NO_GLU $(CFLAGS) $(CFLAGS.SO) -o $# -c $<
# Install targets
install.all: install install.mx install.bin
install: install.include install.lib install.pkgconfig
install.mx: install.include install.lib.mx install.pkgconfig.mx
install.lib: glew.lib
$(INSTALL) -d -m 0755 "$(DESTDIR)$(LIBDIR)"
# runtime
ifeq ($(filter-out mingw% cygwin,$(SYSTEM)),)
$(INSTALL) -d -m 0755 "$(DESTDIR)$(BINDIR)"
$(INSTALL) -m 0755 lib/$(LIB.SHARED) "$(DESTDIR)$(BINDIR)/"
else
$(INSTALL) -m 0644 lib/$(LIB.SHARED) "$(DESTDIR)$(LIBDIR)/"
endif
ifneq ($(LN),)
$(LN) $(LIB.SHARED) "$(DESTDIR)$(LIBDIR)/$(LIB.SONAME)"
endif
# development files
ifeq ($(filter-out mingw% cygwin,$(SYSTEM)),)
$(INSTALL) -m 0644 lib/$(LIB.DEVLNK) "$(DESTDIR)$(LIBDIR)/"
endif
ifneq ($(LN),)
$(LN) $(LIB.SHARED) "$(DESTDIR)$(LIBDIR)/$(LIB.DEVLNK)"
endif
$(INSTALL) -m 0644 lib/$(LIB.STATIC) "$(DESTDIR)$(LIBDIR)/"
install.lib.mx: glew.lib.mx
$(INSTALL) -d -m 0755 "$(DESTDIR)$(LIBDIR)"
# runtime
ifeq ($(filter-out mingw% cygwin,$(SYSTEM)),)
$(INSTALL) -d -m 0755 "$(DESTDIR)$(BINDIR)"
$(INSTALL) -m 0755 lib/$(LIB.SHARED.MX) "$(DESTDIR)$(BINDIR)/"
else
$(INSTALL) -m 0644 lib/$(LIB.SHARED.MX) "$(DESTDIR)$(LIBDIR)/"
endif
ifneq ($(LN),)
$(LN) $(LIB.SHARED.MX) "$(DESTDIR)$(LIBDIR)/$(LIB.SONAME.MX)"
endif
# development files
ifeq ($(filter-out mingw% cygwin,$(SYSTEM)),)
$(INSTALL) -m 0644 lib/$(LIB.DEVLNK.MX) "$(DESTDIR)$(LIBDIR)/"
endif
ifneq ($(LN),)
$(LN) $(LIB.SHARED.MX) "$(DESTDIR)$(LIBDIR)/$(LIB.DEVLNK.MX)"
endif
$(INSTALL) -m 0644 lib/$(LIB.STATIC.MX) "$(DESTDIR)$(LIBDIR)/"
install.bin: glew.bin
$(INSTALL) -d -m 0755 "$(DESTDIR)$(BINDIR)"
$(INSTALL) -s -m 0755 bin/$(GLEWINFO.BIN) bin/$(VISUALINFO.BIN) "$(DESTDIR)$(BINDIR)/"
install.include:
$(INSTALL) -d -m 0755 "$(DESTDIR)$(INCDIR)"
$(INSTALL) -m 0644 include/GL/wglew.h "$(DESTDIR)$(INCDIR)/"
$(INSTALL) -m 0644 include/GL/glew.h "$(DESTDIR)$(INCDIR)/"
$(INSTALL) -m 0644 include/GL/glxew.h "$(DESTDIR)$(INCDIR)/"
install.pkgconfig: glew.pc
$(INSTALL) -d -m 0755 "$(DESTDIR)$(LIBDIR)"
$(INSTALL) -d -m 0755 "$(DESTDIR)$(LIBDIR)/pkgconfig"
$(INSTALL) -m 0644 glew.pc "$(DESTDIR)$(LIBDIR)/pkgconfig/"
install.pkgconfig.mx: glewmx.pc
$(INSTALL) -d -m 0755 "$(DESTDIR)$(LIBDIR)"
$(INSTALL) -d -m 0755 "$(DESTDIR)$(LIBDIR)/pkgconfig"
$(INSTALL) -m 0644 glewmx.pc "$(DESTDIR)$(LIBDIR)/pkgconfig/"
uninstall:
$(RM) "$(DESTDIR)$(INCDIR)/wglew.h"
$(RM) "$(DESTDIR)$(INCDIR)/glew.h"
$(RM) "$(DESTDIR)$(INCDIR)/glxew.h"
$(RM) "$(DESTDIR)$(LIBDIR)/$(LIB.DEVLNK)" "$(DESTDIR)$(LIBDIR)/$(LIB.DEVLNK.MX)"
ifeq ($(filter-out mingw% cygwin,$(SYSTEM)),)
$(RM) "$(DESTDIR)$(BINDIR)/$(LIB.SHARED)" "$(DESTDIR)$(BINDIR)/$(LIB.SHARED.MX)"
else
$(RM) "$(DESTDIR)$(LIBDIR)/$(LIB.SONAME)" "$(DESTDIR)$(LIBDIR)/$(LIB.SONAME.MX)"
$(RM) "$(DESTDIR)$(LIBDIR)/$(LIB.SHARED)" "$(DESTDIR)$(LIBDIR)/$(LIB.SHARED.MX)"
endif
$(RM) "$(DESTDIR)$(LIBDIR)/$(LIB.STATIC)" "$(DESTDIR)$(LIBDIR)/$(LIB.STATIC.MX)"
$(RM) "$(DESTDIR)$(BINDIR)/$(GLEWINFO.BIN)" "$(DESTDIR)$(BINDIR)/$(VISUALINFO.BIN)"
clean:
$(RM) -r tmp/
$(RM) -r lib/
$(RM) -r bin/
$(RM) glew.pc glewmx.pc
distclean: clean
find . -name \*~ | xargs $(RM)
find . -name .\*.sw\? | xargs $(RM)
# Distributions
dist-win32:
$(RM) -r $(DIST_DIR)
mkdir -p $(DIST_DIR)
cp -a include $(DIST_DIR)
cp -a doc $(DIST_DIR)
cp -a *.txt $(DIST_DIR)
cp -a bin $(DIST_DIR)
cp -a lib $(DIST_DIR)
$(RM) -f $(DIST_DIR)/bin/*/*/*.pdb $(DIST_DIR)/bin/*/*/*.exp
$(RM) -f $(DIST_DIR)/bin/*/*/glewinfo-*.exe $(DIST_DIR)/bin/*/*/visualinfo-*.exe
$(RM) -f $(DIST_DIR)/lib/*/*/*.pdb $(DIST_DIR)/lib/*/*/*.exp
unix2dos $(DIST_DIR)/include/GL/*.h
unix2dos $(DIST_DIR)/doc/*.txt
unix2dos $(DIST_DIR)/doc/*.html
unix2dos $(DIST_DIR)/*.txt
rm -f $(DIST_WIN32)
cd $(DIST_DIR)/.. && zip -rv9 $(DIST_WIN32) $(DIST_NAME)
$(RM) -r $(DIST_DIR)
dist-src:
$(RM) -r $(DIST_DIR)
mkdir -p $(DIST_DIR)
mkdir -p $(DIST_DIR)/bin
mkdir -p $(DIST_DIR)/lib
cp -a auto $(DIST_DIR)
$(RM) -Rf $(DIST_DIR)/auto/registry
cp -a build $(DIST_DIR)
cp -a config $(DIST_DIR)
cp -a src $(DIST_DIR)
cp -a doc $(DIST_DIR)
cp -a include $(DIST_DIR)
cp -a *.txt $(DIST_DIR)
cp -a Makefile $(DIST_DIR)
cp -a glew.pc.in $(DIST_DIR)
find $(DIST_DIR) -name '*.o' | xargs $(RM) -r
find $(DIST_DIR) -name '*~' | xargs $(RM) -r
find $(DIST_DIR) -name CVS -o -name .cvsignore | xargs $(RM) -r
find $(DIST_DIR) -name .svn | xargs $(RM) -r
find $(DIST_DIR) -name "*.patch" | xargs $(RM) -r
dos2unix $(DIST_DIR)/Makefile
dos2unix $(DIST_DIR)/auto/Makefile
dos2unix $(DIST_DIR)/config/*
unix2dos $(DIST_DIR)/auto/core/*
unix2dos $(DIST_DIR)/auto/extensions/*
find $(DIST_DIR) -name '*.h' | xargs unix2dos
find $(DIST_DIR) -name '*.c' | xargs unix2dos
find $(DIST_DIR) -name '*.txt' | xargs unix2dos
find $(DIST_DIR) -name '*.html' | xargs unix2dos
find $(DIST_DIR) -name '*.css' | xargs unix2dos
find $(DIST_DIR) -name '*.sh' | xargs unix2dos
find $(DIST_DIR) -name '*.pl' | xargs unix2dos
find $(DIST_DIR) -name 'Makefile' | xargs unix2dos
find $(DIST_DIR) -name '*.in' | xargs unix2dos
find $(DIST_DIR) -name '*.pm' | xargs unix2dos
find $(DIST_DIR) -name '*.rc' | xargs unix2dos
rm -f $(DIST_SRC_ZIP)
cd $(DIST_DIR)/.. && zip -rv9 $(DIST_SRC_ZIP) $(DIST_NAME)
dos2unix $(DIST_DIR)/Makefile
dos2unix $(DIST_DIR)/auto/Makefile
dos2unix $(DIST_DIR)/config/*
dos2unix $(DIST_DIR)/auto/core/*
dos2unix $(DIST_DIR)/auto/extensions/*
find $(DIST_DIR) -name '*.h' | xargs dos2unix
find $(DIST_DIR) -name '*.c' | xargs dos2unix
find $(DIST_DIR) -name '*.txt' | xargs dos2unix
find $(DIST_DIR) -name '*.html' | xargs dos2unix
find $(DIST_DIR) -name '*.css' | xargs dos2unix
find $(DIST_DIR) -name '*.sh' | xargs dos2unix
find $(DIST_DIR) -name '*.pl' | xargs dos2unix
find $(DIST_DIR) -name 'Makefile' | xargs dos2unix
find $(DIST_DIR) -name '*.in' | xargs dos2unix
find $(DIST_DIR) -name '*.pm' | xargs dos2unix
find $(DIST_DIR) -name '*.rc' | xargs dos2unix
rm -f $(DIST_SRC_TGZ)
cd $(DIST_DIR)/.. && env GZIP=-9 tar cvzf $(DIST_SRC_TGZ) $(DIST_NAME)
$(RM) -r $(DIST_DIR)
extensions:
$(MAKE) -C auto
.PHONY: clean distclean tardist dist-win32 dist-src
I'm not really knowledgeable about this stuff myself.
I fixed it. In my PATH variable, I had included both C:\MinGW\bin and C:\cygwin\bin. Removing C:\cygwin\bin did the trick. My thought process was that I should remove 1 of them, since they both contain a make executable.
I don't know why this worked, so if someone could exlpain, that would be nice.
Related
# Docker Chain
src_files:=$(shell find src/ -name '*.py')
image_tags=$(shell find dkr/ -name '$(PROJECT).*.dockerfile' | xargs -n 1 basename -s '.dockerfile')
dkr/%.dockerfile: $(src_files)
docker build . -f $# -t $*
.SECONDEXPANSION:
$(PROJECT).base: dkr/$$#.dockerfile
.SECONDEXPANSION:
$(PROJECT).foo: $(PROJECT).base | dkr/$$#.dockerfile
.SECONDEXPANSION:
$(PROJECT).bar: $(PROJECT).base | dkr/$$#.dockerfile
publish-%:
$(MAKE) $*
./scripts/$#.sh $(RESOURCE_PREFIX) $* $(REGION)
publish:
$(foreach tag, $(image_tags), $(MAKE) publish-$(tag))
I would like to write the above as:
# Docker Chain
src_files:=$(shell find src/ -name '*.py')
image_tags=$(shell find dkr/ -name '$(PROJECT).*.dockerfile' | xargs -n 1 basename -s '.dockerfile')
dkr/%.dockerfile: $(src_files)
docker build . -f $# -t $*
.SECONDEXPANSION:
$(PROJECT).base: dkr/$$#.dockerfile
.SECONDEXPANSION:
$(PROJECT).%: $(PROJECT).base | dkr/$$#.dockerfile
publish-%:
$(MAKE) $*
./scripts/$#.sh $(RESOURCE_PREFIX) $* $(REGION)
publish:
$(foreach tag, $(image_tags), $(MAKE) publish-$(tag))
However, the wildcarding in the rule (via '%') does not work. I suppose I have misunderstood rule substitution, and am guessing it is due to the SECONEXPANSION.
But, my make intuition is telling me this should work, and it should be good.
How would I perform substitution in this scenario?
My currently working makefile uses gcc to compile and link in one step. It is 600 lines long so I have cut it down to just show you the 'compile and link' and hex stages (very cut down code here!)
$(PROGRAM_ELF): \
$(BSP_DIR)/install/lib/$(CONFIGURATION)/libmetal.a \
$(BSP_DIR)/install/lib/$(CONFIGURATION)/libmetal-gloss.a \
$(BSP_DIR)/metal.$(LINK_TARGET).lds
mkdir -p $(dir $#)
$(MAKE) -C $(SRC_DIR) $(basename $(notdir $#)) \
PORT_DIR=$(PORT_DIR) \
AR=$(RISCV_AR) \
CC=$(RISCV_GCC) \
CXX=$(RISCV_GXX) \
ASFLAGS="$(RISCV_ASFLAGS)" \
CCASFLAGS="$(RISCV_CCASFLAGS)" \
CFLAGS="$(RISCV_CFLAGS)" \
CXXFLAGS="$(RISCV_CXXFLAGS)" \
XCFLAGS="$(RISCV_XCFLAGS)" \
LDFLAGS="$(RISCV_LDFLAGS)" \
LDLIBS="$(RISCV_LDLIBS)" \
PROJ_SRC="$(PROJ_SRC)"
$(PROGRAM_HEX): \
$(PROGRAM_ELF)
$(RISCV_OBJCOPY) -O ihex $(PROGRAM_ELF) $#
mv $(PROGRAM_HEX) $(PROGRAM_TMP)
$(RISCV_OBJCOPY) -O verilog $(PROGRAM_ELF) $#
cp $(PROGRAM_HEX) $(PROGRAM_MEM)
mv $(PROGRAM_TMP) $(PROGRAM_HEX)
However, I need the 'compile and link stage' to be in 2 steps now as I'll be using a different compiler which has separate compile and link exes. How would I do this ? So the above would need to be split into 2. Examples online are a bit vague.
at its simplest, you use the gcc (or g++) -c option to compile the source without linking. This will generate an object file - which you can use in the linker state. Here is a simple example:
SOURCE = test.cpp
OBJECT = test.o
OUTPUT = run
all:
#g++ $(SOURCE) -c -o $(OBJECT) <------ Compile test.cpp, produces test.o
#g++ $(OBJECT) -o $(OUTPUT) <------ Links test.o into executable `run`
clean:
#$(RM) -rf $(OBJECT) $(OUTPUT)
That's it...
I did this which seemed to work:
#list of all files
PROJ_SRC = $(SRC_DIR)/plsi2c_riscv.c \
$(SRC_DIR)/SimSpi.c \
etc
#assume BUILD_FOLDER defined already
OBJ_FILES = $(addprefix $(BUILD_FOLDER)/,$(PROJ_SRC:.c=.o))
$(BUILD_FOLDER)/%.o: %.c
#Create the folder structure for the output file
#mkdir -p $(dir $#)
$(MY_CC) $(CCFLAGS) $< -o $#
$(BUILD_FOLDER)/example: $(OBJ_FILES)
mkdir -p $(dir $#)
#echo Linking $(notdir $#)
$(MY_LINK) $(LFLAGS) $^ $(LDLIBS) -o $#
I have a circular dependency using make:
CC = gcc
IFLAGS = -Iinclude
CFLAGS = -Wall -g -c -fPIC -pedantic
AFLAGS = -shared
LFLAGS =
VERSION = $(shell cat desc/major).$(shell cat desc/minor).$(shell cat desc/patch)
DFLAGS = -D_XOPEN_SOURCE=700 -DLTKVER=\"$(VERSION)\"
OBJECTS = $(patsubst src/%.c,tmp/%.o, $(shell ls -1 src/*.c))
#OUTPUT = tmp/$(lastword $(subst /, ,$(shell pwd)))
OUT_BIN = install/usr/lib/libLTK.so
OUT_MAN = $(patsubst man/%,install/usr/share/man/%.gz, $(shell find man -type f))
PATH_INCLUDE = install/usr/include/LTK-$(VERSION)
OUT_INCLUDE = $(patsubst %,$(PATH_INCLUDE)/%, $(shell find include -type f -printf "%f\n"))
PC = %
all: $(OUT_BIN) $(OUT_MAN) $(OUT_INCLUDE)
# chmod 755 install/usr/lib/libLTK.so.$(VERSION)
ln -sf install/usr/lib/libLTK.so.$(VERSION) install/usr/lib/libLTK.so
# chmod 755 install/usr/include/LTK-$(VERSION)
# chmod 644 install/usr/include/LTK-$(VERSION)/*
ln -sf install/usr/include/LTK-$(VERSION) install/usr/include/LTK
$(OUT_BIN): $(OBJECTS)
mkdir -p $(shell dirname $#)
$(CC) $(AFLAGS) -o $#.$(VERSION) $^ $(LFLAGS)
tmp/%.o : src/%.c
mkdir -p $(shell dirname $#)
$(CC) $(CFLAGS) -o $# $< $(DFLAGS) $(IFLAGS)
install/usr/share/%.gz : %
mkdir -p $(shell dirname $#)
gzip -c $< > $#
.SECONDEXPANSION:
%.h : $$(patsubst $(PATH_INCLUDE)/$$(PC),include/$$(PC),$$#)
mkdir -p $(shell dirname $$#)
cp $< $$#
clean:
rm -rf tmp install
At second expansion header files, prerequisites are generated from second expansions.
But it's a header that generates another and this new one can be found on the disk.
But make rather prefers to consider a circular dependency and ignore it.
How can I force make to see that the file exists before it searches a target to generate it?
Circular dependences are completely independent of what exists on the disk or doesn't exist on the disk. When make runs it parses the makefile and constructs a graph representing the dependency relationship between targets. This graph must be acyclic, because make will walk the graph looking for whether targets are out of date. If there's a cycle in the graph, then make would recurse forever trying to walk the graph.
For example:
a: b ; touch $#
b: a ; touch $#
It doesn't matter whether these files exist or not: make still needs to be sure that "a" is newer than "b" to satisfy the first dependency, and that "b" is newer than "a" to satisfy the second dependency.
This cannot ever be true, obviously.
Finally resolved by substituing $(OUT_INCLUDE) to %.h.
The goal to auto copy include files is preserved.
Substitued this:
.SECONDEXPANSION:
$(OUT_INCLUDE) : $$(patsubst $(PATH_INCLUDE)/$$(PERCENT),include/$$(PERCENT),$$#)
mkdir -p $(shell dirname $#)
cp $< $#
For this:
.SECONDEXPANSION:
%.h : $$(patsubst $(PATH_INCLUDE)/$$(PC),include/$$(PC),$$#)
mkdir -p $(shell dirname $$#)
cp $< $$#
But I'm still asking myself on "is there anything to force file before dependency".
After looking at the code it looks like no, unless I omit something.
I have the following rules in a Makefile to build an executable in 3 stages:
all: build/myexe
build/myexe: output/main_dats.o output/foo_dats.o | build/
gcc $^ -o $#
output/%.o: output/%.c
patscc -c $< -o $#
output/%_dats.c: src/%.dats | output/
patsopt -cc -o $# -d $<
build/:
mkdir -p build/
output/:
mkdir -p output/
An src/%.dats source file is used to generate an output/%_dats.c source file which is compiled to an output/%.o object file and finally they are linked into the executable build/myexe.
Running make the first time will only successfully build the first of the two .o files:
$ make
mkdir -p output/
patsopt -cc -o output/main_dats.c -d src/main.dats
patscc -c output/main_dats.c -o output/main_dats.o
make: *** No rule to make target `output/foo_dats.o', needed by `build/myexe'. Stop.
rm output/main_dats.c
But running again will build the second .o file and successfully link the executable:
$ make
patsopt -cc -o output/foo_dats.c -d src/foo.dats
patscc -c output/foo_dats.c -o output/foo_dats.o
mkdir -p build/
gcc output/main_dats.o output/foo_dats.o -o build/myexe
rm output/foo_dats.c
and note that at the end of each invocation the command rm output/..._dats.c is deleting the generated .c source file.
Here is a Makefile written without pattern matching:
all: build/myexe
build/myexe: output/main_dats.o output/foo_dats.o | build/
gcc $^ -o $#
output/foo_dats.o: output/foo_dats.c
patscc -c $< -o $#
output/main_dats.o: output/main_dats.c
patscc -c $< -o $#
output/foo_dats.c: src/foo.dats | output/
patsopt -cc -o $# -d $<
output/main_dats.c: src/main.dats | output/
patsopt -cc -o $# -d $<
build/:
mkdir -p build/
output/:
mkdir -p output/
which works more predictably:
$ make
mkdir -p output/
patsopt -cc -o output/main_dats.c -d src/main.dats
patscc -c output/main_dats.c -o output/main_dats.o
patsopt -cc -o output/foo_dats.c -d src/foo.dats
patscc -c output/foo_dats.c -o output/foo_dats.o
mkdir -p build/
gcc output/main_dats.o output/foo_dats.o -o build/myexe
and note that the generated .c files are not being removed any more.
Apparently I am misusing the pattern matching mechanism. I know there is some kind of wildcard function but I believe it is intended for file globbing.
To avoid removing intermediate files, you just need to list them as actual targets somewhere. For example you could write a separate rule:
make_srcs: output/main_dats.c output/foo_dats.c
You don't have to list this target make_srcs as a prerequisite, or provide it a recipe, etc. Just listing the _dats.c files as actual targets or prerequisites in the makefile is enough to keep them from being deleted.
As for your "only building some output" behavior, I don't know: it works fine for me:
$ make --version | head -n1
GNU Make 4.2.1
$ cat Makefile
all: build/myexe
build/myexe: output/main_dats.o output/foo_dats.o | build/
touch $#
output/%.o: output/%.c
touch $#
output/%_dats.c: src/%.dats | output/
touch $#
build/:
mkdir -p build/
output/:
mkdir -p output/
make_srcs: output/main_dats.c output/foo_dats.c
$ rm -rf output build && make
mkdir -p output/
touch output/main_dats.c
touch output/main_dats.o
touch output/foo_dats.c
touch output/foo_dats.o
mkdir -p build/
touch build/myexe
So there's something about your setup which hasn't been made clear in your question. As the comment suggested you need to run make -d (I would leave off the -R option, I don't know why you'd add that) and figure out why make throws that error.
Pattern rules should ideally be deprecated. They are prone to over-matching (because, well, patterns), they can be hard to get working, they bring with them the whole "intermediate target" issue (that's the deletion of output/*.c files that you are observing), they need another dubious feature ("secondary expansion") to make them usable in some more involved scenarios, etc.
In short: using pattern rules is not advised, and using multi-level pattern rules is definitely not advised. Just more trouble than it's worth. IMHO, anyway.
(end rant)
So I suggest that you write a simple macro instead, so your makefile ends up looking like this:
all: build/myexe
# $(call dats,basename)
define dats
output/$1_dats.o: output/$1_dats.c
patscc -c $$< -o $$#
output/$1_dats.c: src/$1.c | output
patcc -cc -o $$# -d $$<
endif
build/myexe: output/main_dats.o output/foo_dats.o | build
gcc $^ -o $#
$(eval $(call dats,foo))
$(eval $(call dats,main))
build:
mkdir -p build
output:
mkdir -p output
I am trying to run trimesh2 on my 64-bit debian,
but whenever I try to run mesh_view or any other mesh command, it says
cannot execute binary file
What should I do to run the mesh? The Makefile looks like this:
all win32 linux32 linux64 darwin32 darwin64 clean:
$(MAKE) -C libsrc $#
$(MAKE) -C gluit $#
$(MAKE) -C utilsrc $#
debug:
$(MAKE) -C libsrc DEBUG=y
$(MAKE) -C gluit DEBUG=y
$(MAKE) -C utilsrc DEBUG=y
FINDCMD = find trimesh2 -name 'OBJ*' -prune -o -name CVS -prune -o -type f -print
tar:
cd .. && tar zcvf trimesh2.tar.gz `$(FINDCMD) | sort`
zip:
cd .. && $(FINDCMD) | sort | zip -9 trimesh2 -#
.PHONY : all clean debug default tar win32 zip