Problem with "OpenWrt Hello, world" tutorial's Makefile

I'm following along with the tutorial, and when I try to compile:

make V=sc package/helloworld/compile

I get the following error:

Makefile:48: *** missing separator.   Stop.

Am I doing anything wrong? The makefile format seems to be correct.

Here's my Makefile:

include $(TOPDIR)/rules.mk

# Name, version and release number
# The name and version of your package are used to define the variable to point                                                                   to the build directory of your package: $(PKG_BUILD_DIR)
PKG_NAME:=helloworld
PKG_VERSION:=1.0
PKG_RELEASE:=1

# Source settings (i.e. where to find the source codes)
# This is a custom variable, used below
SOURCE_DIR:=/home/coop-2/helloworld

include $(INCLUDE_DIR)/package.mk

# Package definition; instructs on how and where our package will appear in the                                                                   overall configuration menu ('make menuconfig')
define Package/helloworld
  SECTION:=examples
  CATEGORY:=Examples
  TITLE:=Hello, World!
endef

# Package description; a more verbose description on what our package does
define Package/helloworld/description
  A simple "Hello, world!" -application.
endef

# Package preparation instructions; create the build directory and copy the sour                                                                  ce code.
# The last command is necessary to ensure our preparation instructions remain co                                                                  mpatible with the patching system.
define Build/Prepare
  mkdir -p $(PKG_BUILD_DIR)
  cp $(SOURCE_DIR)/* $(PKG_BUILD_DIR)
  $(Build/Patch)
endef

# Package build instructions; invoke the target-specific compiler to first compi                                                                  le the source file, and then to link the file into the final executable
define Build/Compile
  $(TARGET_CC) $(TARGET_CFLAGS) -o $(PKG_BUILD_DIR)/helloworld.o -c $(PKG_BUILD_                                                                  DIR)/helloworld.c
  $(TARGET_CC) $(TARGET_LDFLAGS) -o $(PKG_BUILD_DIR)/$1 $(PKG_BUILD_DIR)/hellowo                                                                  rld.o
endef

# Package install instructions; create a directory inside the package to hold ou                                                                  r executable, and then copy the executable we built previously into the folder
define Package/helloworld/install
  $(INSTALL_DIR) $(1)/usr/bin
  $(INSTALL_BIN) $(PKG_BUILD_DIR)/helloworld $(1)/usr/bin
endef

# This command is always the last, it uses the definitions and variables we give                                                                   above in order to get the job done
$(eval $(call BuildPackage,helloworld))

Here's my PATH:

echo $PATH
/home/coop-2/openwrt/staging_dir/host/bin/: etc...

Here's my code:

cat ~/helloworld/helloworld.c
#include <stdio.h>
int main(void) {printf("Hello, World\n"); return 0; }

Here's my target:
Target System: MediaTek Ralink MIPS
Subtarget: MT7621 based boards
Target Profile: Zbtlink ZBT-WE3526

And lastly, my make version:

make --version
GNU Make 4.2.1
Built for x86_64-pc-linux-gnu
...

The lines in the Build/Compile and Package/helloworld/install sections must be indented with one tab character.

1 Like

Thank you, I had my vim settings expand tab characters. This was a hard one to catch!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.